Skip to content

Commit

Permalink
checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
alevenberg committed Dec 7, 2023
1 parent df57faf commit 92cd66e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion pubsub-open-telemetry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ target_link_libraries(publisher PRIVATE publisher_helper parse_args)

add_executable(publisher_zipkin publisher_zipkin.cc)
target_compile_features(publisher_zipkin PRIVATE cxx_std_14)
target_link_libraries(publisher_zipkin PRIVATE publisher_helper parse_args opentelemetry-cpp::opentelemetry_exporter_zipkin_trace)
target_link_libraries(
publisher_zipkin
PRIVATE publisher_helper parse_args
opentelemetry-cpp::opentelemetry_exporter_zipkin_trace)

add_executable(quickstart quickstart.cc)
target_compile_features(quickstart PRIVATE cxx_std_14)
Expand Down
4 changes: 4 additions & 0 deletions pubsub-open-telemetry/publisher.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ If you do not already, have one create a local Zipkin instance.
#### (optional) Create a local Zipkin instance.

To run Zipkin on the host `http://localhost:9411`

```shell
docker run -d -p 9411:9411 openzipkin/zipkin
```

To kill the instance

```shell
docker container ls
docker rm -f openzipkin/zipkin
Expand All @@ -104,6 +106,7 @@ docker rm -f openzipkin/zipkin
## Build and run

### Using CMake and Vcpkg

#### Run the publisher with Zipkin

```sh
Expand All @@ -113,6 +116,7 @@ cmake --build .build
```

#### Run basic publisher examples

```shell
.build/publisher_zipkin [project-name] [topic-id]
.build/publisher_zipkin [project-name] [topic-id] -n 1000
Expand Down
16 changes: 8 additions & 8 deletions pubsub-open-telemetry/publisher_zipkin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "google/cloud/pubsub/publisher.h"
#include "google/cloud/opentelemetry/trace_exporter.h"
#include "google/cloud/pubsub/publisher.h"
#include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h"
#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h"
#include "parse_args.h"
#include "publisher_helper.h"
#include <opentelemetry/sdk/trace/batch_span_processor_factory.h>
#include <opentelemetry/sdk/trace/batch_span_processor_options.h>
#include <opentelemetry/sdk/trace/processor.h>
#include <opentelemetry/sdk/trace/tracer_provider_factory.h>
#include <opentelemetry/trace/provider.h>
#include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h"
#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h"
#include <iostream>

// Create a few namespace aliases to make the code easier to read.
Expand All @@ -32,18 +32,18 @@ namespace trace_sdk = ::opentelemetry::sdk::trace;
namespace trace = ::opentelemetry::trace;
namespace zipkin = opentelemetry::exporter::zipkin;

void ConfigureZipkinTracer(ParseResult const& args) {
void ConfigureZipkinTracer(ParseResult const& args) {
auto exporter = zipkin::ZipkinExporterFactory::Create();

trace_sdk::BatchSpanProcessorOptions span_options;
span_options.max_queue_size = args.max_queue_size;
auto processor = trace_sdk::BatchSpanProcessorFactory::Create(
std::move(exporter), span_options);
auto provider = trace_sdk::TracerProviderFactory::Create(
std::move(processor));
auto provider =
trace_sdk::TracerProviderFactory::Create(std::move(processor));

trace::Provider::SetTracerProvider(std::move(provider));
}
trace::Provider::SetTracerProvider(std::move(provider));
}

int main(int argc, char* argv[]) try {
auto args = ParseArguments(argc, argv);
Expand Down

0 comments on commit 92cd66e

Please sign in to comment.