Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit c064c22

Browse files
author
Bogdan Drutu
authored
Add version to the Stackdriver agent label. (#188)
* Add version to the Stackdriver agent label. * Update version to 0.3.0-dev. * Change artifact name to version and make it package only.
1 parent 21ff1f2 commit c064c22

4 files changed

Lines changed: 53 additions & 1 deletion

File tree

opencensus/common/BUILD

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# OpenCensus C++ Common library.
2+
# See ../../README.md for details.
3+
#
4+
# Copyright 2018, OpenCensus Authors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
load("//opencensus:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
19+
20+
licenses(["notice"]) # Apache 2.0
21+
22+
package(default_visibility = ["//opencensus:__subpackages__"])
23+
24+
cc_library(
25+
name = "version",
26+
hdrs = ["version.h"],
27+
copts = DEFAULT_COPTS,
28+
)

opencensus/common/version.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2018, OpenCensus Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef OPENCENSUS_COMMON_VERSION_H_
16+
#define OPENCENSUS_COMMON_VERSION_H_
17+
18+
// The current version of the opencensus core library. Macro to allow literal
19+
// string concatenation in constexpr statements.
20+
#define OPENCENSUS_VERSION "0.3.0-dev"
21+
22+
#endif // OPENCENSUS_COMMON_VERSION_H_

opencensus/exporters/trace/stackdriver/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cc_library(
2929
visibility = ["//visibility:public"],
3030
deps = [
3131
"//google/devtools/cloudtrace/v2:tracing_proto",
32+
"//opencensus/common:version",
3233
"//opencensus/common/internal/grpc:status",
3334
"//opencensus/trace",
3435
"@com_github_grpc_grpc//:grpc++",

opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "absl/time/clock.h"
2525
#include "google/devtools/cloudtrace/v2/tracing.grpc.pb.h"
2626
#include "opencensus/common/internal/grpc/status.h"
27+
#include "opencensus/common/version.h"
2728
#include "opencensus/trace/exporter/span_data.h"
2829
#include "opencensus/trace/exporter/span_exporter.h"
2930

@@ -38,7 +39,7 @@ constexpr size_t kDisplayNameStringLen = 128;
3839
constexpr char kGoogleStackdriverTraceAddress[] = "cloudtrace.googleapis.com";
3940

4041
constexpr char kAgentKey[] = "g.co/agent";
41-
constexpr char kAgentValue[] = "opencensus-cpp";
42+
constexpr char kAgentValue[] = "opencensus-cpp [" OPENCENSUS_VERSION "]";
4243

4344
bool Validate(const google::protobuf::Timestamp& t) {
4445
const auto sec = t.seconds();

0 commit comments

Comments
 (0)