Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
Loading...
Searching...
No Matches
request_span.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2021 Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include <cinttypes>
21#include <memory>
22#include <string>
23
24namespace couchbase::tracing
25{
27{
28public:
29 request_span() = default;
30 request_span(const request_span& other) = default;
31 request_span(request_span&& other) = default;
32 auto operator=(const request_span& other) -> request_span& = default;
33 auto operator=(request_span&& other) -> request_span& = default;
34 virtual ~request_span() = default;
35
36 explicit request_span(std::string name)
37 : name_(std::move(name))
38 {
39 }
40 request_span(std::string name, std::shared_ptr<request_span> parent)
41 : name_(std::move(name))
42 , parent_(std::move(parent))
43 {
44 }
45 virtual void add_tag(const std::string& name, std::uint64_t value) = 0;
46 virtual void add_tag(const std::string& name, const std::string& value) = 0;
47 virtual void end() = 0;
48
49 [[nodiscard]] auto name() const -> const std::string&
50 {
51 return name_;
52 }
53
54 [[nodiscard]] auto parent() const -> std::shared_ptr<request_span>
55 {
56 return parent_;
57 }
58
59 virtual auto uses_tags() const -> bool
60 {
61 return true;
62 }
63
64private:
65 std::string name_{};
66 std::shared_ptr<request_span> parent_{ nullptr };
67};
68} // namespace couchbase::tracing
Definition request_span.hxx:27
auto parent() const -> std::shared_ptr< request_span >
Definition request_span.hxx:54
request_span(std::string name)
Definition request_span.hxx:36
request_span(request_span &&other)=default
virtual auto uses_tags() const -> bool
Definition request_span.hxx:59
request_span(std::string name, std::shared_ptr< request_span > parent)
Definition request_span.hxx:40
auto operator=(request_span &&other) -> request_span &=default
auto name() const -> const std::string &
Definition request_span.hxx:49
request_span(const request_span &other)=default
virtual void add_tag(const std::string &name, const std::string &value)=0
auto operator=(const request_span &other) -> request_span &=default
virtual void add_tag(const std::string &name, std::uint64_t value)=0
Definition otel_tracer.hxx:28