### Setup Build Tools and Dependencies Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vs2019.md Installs necessary build tools like CMake and downloads/compiles required C++ dependencies using vcpkg. This is a one-time setup step that requires administrator privileges and can take up to 5-10 minutes. ```console cd opentelemetry-cpp tools\setup-buildtools.cmd ``` -------------------------------- ### Start HTTP Server Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/http/README.md Starts the HTTP server on a specified port. This is the first step to run the client-server tracing example. ```console $ http_server 8800 Server is running..Press ctrl-c to exit... ``` -------------------------------- ### Build Example with Bazel Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/CONTRIBUTING.md Build a specific example from the examples folder using Bazel. Replace placeholders with your example's directory and binary name. ```bash bazel build //examples/: ``` -------------------------------- ### Example Main Function Setup (C++) Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/explicit_parent/README.md Sets up the OpenTelemetry SDK and demonstrates the explicit parent span pattern. It creates two parent spans, captures them in lambdas for deferred execution, and processes them. ```cpp int main(int argc, char **argv) { // Initialize SDK opentelemetry::exporter::trace::OstreamSpanExporter ostream_exporter; opentelemetry::sdk::trace::BatchSpanProcessor span_processor(std::move(ostream_exporter)); opentelemetry::sdk::trace::TracerProvider tracer_provider(std::move(span_processor)); opentelemetry::trace::Provider::SetTracerProvider(tracer_provider.get_tracer_provider()); auto tracer = opentelemetry::trace::Provider::GetTracerProvider()->GetTracer("example"); // Create parent spans at registration time auto parent_1 = CreateSpan("parent_1"); auto parent_2 = CreateSpan("parent_2"); // Capture spans in lambdas for later execution auto task_1 = [parent_1]() { ProcessTask(parent_1); }; auto task_2 = [parent_2]() { ProcessTask(parent_2); }; // Queue tasks for execution (simulated) std::vector> tasks; tasks.push_back(task_1); tasks.push_back(task_2); // Process tasks for (auto& task : tasks) { task(); } // Ensure spans are flushed (in a real app, this might be handled by SDK shutdown) std::this_thread::sleep_for(std::chrono::milliseconds(200)); return 0; } ``` -------------------------------- ### Run Example with Bazel Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/CONTRIBUTING.md Execute a built example to observe telemetry output. Ensure the example has been successfully built first. ```bash bazel-bin/examples// ``` -------------------------------- ### Install OpenTelemetry C++ SDK using response file on Linux Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vcpkg.md Installs OpenTelemetry C++ SDK dependencies using a response file, which consolidates vcpkg parameters. This example is specific to Linux. ```console vcpkg install @tools/ports/opentelemetry/response_file_linux.txt ``` -------------------------------- ### Build and Run Simple Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/CONTRIBUTING.md Demonstrates building and running the 'simple' example using Bazel. This is a concrete instance of the general build and run commands. ```bash bazel build //examples/simple:example_simple ``` ```bash bazel-bin/examples/simple/example_simple ``` -------------------------------- ### Build and Run Tracer Configurator Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/tracer_configurator/README.md Execute the compiled example to observe the tracer configuration changes. ```sh ~/build/examples/tracer_configurator/example_tracer_configurator ``` -------------------------------- ### Configure Examples Test Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/CMakeLists.txt Configures the example projects to use the installed OpenTelemetry C++ package. It sets necessary CMake variables and paths for the configuration step. ```cmake set(OPENTELEMETRY_CPP_EXAMPLES_SRC_DIR "${CMAKE_SOURCE_DIR}/../../../examples") # Configure the examples with the installed package add_test( NAME examples-config-test COMMAND ${CMAKE_COMMAND} --log-level=DEBUG -S ${CMAKE_SOURCE_DIR}/examples_test -B examples-test "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${INSTALL_TEST_CMAKE_OPTIONS} "-DOPENTELEMETRY_CPP_EXAMPLES_SRC_DIR=${OPENTELEMETRY_CPP_EXAMPLES_SRC_DIR}" ) ``` -------------------------------- ### Build Examples Test Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/CMakeLists.txt Builds the configured example projects. This command utilizes CMake's build functionality, potentially in parallel, to compile the examples. ```cmake add_test(NAME examples-build-test COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/examples-test --parallel) ``` -------------------------------- ### Build and Link Example Executable Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/multi_processor/CMakeLists.txt Configures the build for the multi-processor example executable, linking necessary OpenTelemetry libraries and common libraries. ```cmake add_executable(example_multi_processor main.cc) target_link_libraries( example_multi_processor PRIVATE common_foo_library opentelemetry-cpp::trace opentelemetry-cpp::ostream_span_exporter opentelemetry-cpp::in_memory_span_exporter) ``` -------------------------------- ### Install Build Tools Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vs2019.md Run this command as administrator to install necessary build tooling and all 3rd party dependencies using vcpkg. ```console tools\setup-buildtools.cmd ``` -------------------------------- ### Run Examples Test Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/CMakeLists.txt Executes the built example projects. This command changes the directory to the examples build output and then runs CTest to execute the examples, showing output on failure. ```cmake add_test(NAME examples-run-test COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/examples-test ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) ``` -------------------------------- ### Install Google Test using CMake Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/google-test.md Steps to download, build, and install Google Test from source using CMake. Ensure you have CMake installed and follow the provided download links for Google Test. ```console mkdir build && cd build cmake .. make make install ``` -------------------------------- ### Install OpenTelemetry C++ SDK using response file on Mac Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vcpkg.md Installs OpenTelemetry C++ SDK dependencies using a response file, which consolidates vcpkg parameters. This example is specific to macOS. ```console vcpkg install @tools/ports/opentelemetry/response_file_mac.txt ``` -------------------------------- ### Run Prometheus Example Application Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/prometheus/README.md Execute the example application that exports metrics using the Prometheus exporter. The exporter defaults to http://localhost:9464/. ```bash bazel run //examples/prometheus:prometheus_example ``` -------------------------------- ### Setup Development Environment (Windows) Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/using-clang-format.md Sets up the build tools environment on Windows by adding necessary tools to the PATH. ```batch call tools\setup-devenv.cmd ``` -------------------------------- ### Configure OTLP gRPC Trace Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/otlp/CMakeLists.txt Adds an executable for the OTLP gRPC trace example and links necessary libraries. Includes conditional linking for DLL builds. ```cmake if(WITH_OTLP_GRPC) # TRACE add_executable(example_otlp_grpc grpc_main.cc) target_link_libraries(example_otlp_grpc PRIVATE common_foo_library) if(DEFINED OPENTELEMETRY_BUILD_DLL) target_compile_definitions(example_otlp_grpc PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL) target_link_libraries(example_otlp_grpc PRIVATE opentelemetry-cpp::opentelemetry_cpp) else() target_link_libraries(example_otlp_grpc PRIVATE opentelemetry-cpp::otlp_grpc_exporter) endif() # METRIC add_executable(example_otlp_grpc_metric grpc_metric_main.cc) target_link_libraries(example_otlp_grpc_metric PRIVATE common_metrics_foo_library) if(DEFINED OPENTELEMETRY_BUILD_DLL) target_compile_definitions(example_otlp_grpc_metric PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL) target_link_libraries(example_otlp_grpc_metric PRIVATE opentelemetry-cpp::opentelemetry_cpp) else() target_link_libraries(example_otlp_grpc_metric PRIVATE opentelemetry-cpp::otlp_grpc_metrics_exporter) endif() # LOG add_executable(example_otlp_grpc_log grpc_log_main.cc) target_link_libraries(example_otlp_grpc_log PRIVATE common_logs_foo_library) if(DEFINED OPENTELEMETRY_BUILD_DLL) target_compile_definitions(example_otlp_grpc_log PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL) target_link_libraries(example_otlp_grpc_log PRIVATE opentelemetry-cpp::opentelemetry_cpp) else() target_link_libraries( example_otlp_grpc_log PRIVATE opentelemetry-cpp::otlp_grpc_exporter opentelemetry-cpp::otlp_grpc_log_record_exporter) endif() endif() if(WITH_OTLP_HTTP) ``` -------------------------------- ### Start Prometheus Server Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/prometheus/README.md Start the Prometheus server using the generated configuration file or a Docker image. This command assumes the configuration file is in the current directory. ```bash ./prometheus --config.file=prometheus.yml ``` ```bash docker run -p 9090:9090 -v $(pwd):/etc/prometheus --network="host" prom/prometheus ``` -------------------------------- ### Setup Development Environment (Linux/Mac) Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/using-clang-format.md Sets up the build tools environment on Linux and Mac by adding necessary tools to the PATH. ```shell . tools/setup-devenv.sh ``` -------------------------------- ### Start OpenTelemetry Collector with SSL Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/testing-with-ssl.md Start the OpenTelemetry collector with SSL/TLS enabled. Ensure the configuration file path is correct. ```console shell> /path/to/bin/otelcorecol_linux_amd64 --config /path/to/otel-config-ssl.yaml ... 2022-12-13T18:03:21.140+0100 info otlpreceiver@v0.66.0/otlp.go:89 Starting HTTP server {"kind": "receiver", "name": "otlp", "pipeline": "metrics", "endpoint": "0.0.0.0:4318"} 2022-12-13T18:03:21.141+0100 info service/pipelines.go:106 Receiver started. {"kind": "receiver", "name": "otlp", "pipeline": "metrics"} 2022-12-13T18:03:21.141+0100 info service/pipelines.go:102 Receiver is starting... {"kind": "receiver", "name": "otlp", "pipeline": "traces"} 2022-12-13T18:03:21.141+0100 info service/pipelines.go:106 Receiver started. {"kind": "receiver", "name": "otlp", "pipeline": "traces"} 2022-12-13T18:03:21.141+0100 info service/service.go:105 Everything is ready. Begin running and processing data. ``` -------------------------------- ### Add Plugin Example Test CMake Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/plugin/CMakeLists.txt Adds a test case for the plugin example. This test executes the load_plugin_example with the example_plugin and an empty configuration file. ```cmake add_test( NAME examples.plugin COMMAND "$" "$" "${CMAKE_CURRENT_BINARY_DIR}/load/empty_config.txt") ``` -------------------------------- ### Install opentelemetry-cpp Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md Optionally install the library components to a specified location. This makes the library available for external projects via `find_package`. ```console $ cmake --install . --prefix // -- Installing: //lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake -- Installing: //lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config-version.cmake ... $ ``` -------------------------------- ### CMakeLists.txt for SDK Install Test Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/component_tests/sdk/CMakeLists.txt Configures the build for an SDK installation test. It finds the installed OpenTelemetry C++ SDK components and links them with Google Test for verification. ```cmake # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 cmake_minimum_required(VERSION 3.16) project(opentelemetry-cpp-sdk-install-test LANGUAGES CXX) find_package(opentelemetry-cpp REQUIRED COMPONENTS sdk) if(NOT TARGET Threads::Threads) message(FATAL_ERROR "Threads::Threads target not found") endif() find_package(GTest CONFIG REQUIRED) include(GoogleTest) add_executable(sdk_test ${INSTALL_TEST_SRC_DIR}/test_sdk.cc) target_link_libraries( sdk_test PRIVATE opentelemetry-cpp::api opentelemetry-cpp::sdk opentelemetry-cpp::version opentelemetry-cpp::common opentelemetry-cpp::resources opentelemetry-cpp::trace opentelemetry-cpp::metrics opentelemetry-cpp::logs GTest::gtest GTest::gtest_main) gtest_discover_tests(sdk_test) ``` -------------------------------- ### Start W3C Trace Context Test Server Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/ext/test/w3c_tracecontext_http_test_server/README.md Build and run the test server. A custom port can be specified to change the listening port. ```sh ./w3c_tracecontext_http_test_server Listening to http://localhost:30000/test ``` ```sh ./w3c_tracecontext_http_test_server 31339 Listening to http://localhost:31339/test ``` -------------------------------- ### Run gRPC Server Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/grpc/README.md Starts the gRPC server. Optionally specify a port number. ```console $ ./server [port_num] Server listening on port: 0.0.0.0:8800 ``` -------------------------------- ### Build Example Executable and Link Libraries Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/logs_simple/CMakeLists.txt Defines the executable for the logs simple example and links it with the common logs library. It conditionally links against the OpenTelemetry C++ libraries based on whether DLLs are being built. ```cmake add_executable(example_logs_simple main.cc) target_link_libraries(example_logs_simple PRIVATE common_logs_foo_library) if(DEFINED OPENTELEMETRY_BUILD_DLL) target_compile_definitions(example_logs_simple PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL) target_link_libraries(example_logs_simple PRIVATE opentelemetry-cpp::opentelemetry_cpp) else() target_link_libraries( example_logs_simple PRIVATE opentelemetry-cpp::trace opentelemetry-cpp::logs opentelemetry-cpp::ostream_span_exporter opentelemetry-cpp::ostream_log_record_exporter) endif() ``` -------------------------------- ### Install OpenTelemetry C++ SDK using vcpkg Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vcpkg.md Installs the public open-source release of the OpenTelemetry C++ SDK. This command compiles the package for the current operating system. ```console vcpkg install opentelemetry-cpp ``` -------------------------------- ### CMakeLists.txt for Plugin Loading Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/plugin/load/CMakeLists.txt Configures a CMake project to build an executable that links against the OpenTelemetry C++ API and system dynamic linking libraries. ```cmake # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 add_executable(load_plugin_example main.cc) target_link_libraries(load_plugin_example PRIVATE opentelemetry-cpp::api ${CMAKE_DL_LIBS}) ``` -------------------------------- ### Build metrics_ostream_example Executable Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/metrics_simple/CMakeLists.txt Defines the main executable for the metrics_ostream example. It links against common metrics libraries. ```cmake add_executable(metrics_ostream_example metrics_ostream.cc) target_link_libraries(metrics_ostream_example PRIVATE common_metrics_foo_library) ``` -------------------------------- ### CMakeLists.txt for Zipkin Exporter Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/zipkin/CMakeLists.txt This snippet shows how to add an executable and link it with the Zipkin trace exporter library using CMake. ```cmake # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 add_executable(example_zipkin main.cc) target_link_libraries( example_zipkin PRIVATE common_foo_library opentelemetry-cpp::zipkin_trace_exporter) ``` -------------------------------- ### Specific Bazel Test Command Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/google-test.md A concrete example of the Bazel 'test' command to build and run the 'tracer_provider_test' unit test. ```console bazel test //sdk/test/trace:tracer_provider_test ``` -------------------------------- ### Default Installation Target Setting Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/CMakeLists.txt Determines the default value for the OPENTELEMETRY_INSTALL option based on the source directory. ```cmake set(OPENTELEMETRY_INSTALL_default ON) if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(OPENTELEMETRY_INSTALL_default OFF) endif() ``` -------------------------------- ### Specific Bazel Build and Run Commands Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/google-test.md Concrete examples of Bazel commands for building and running the 'tracer_provider_test' unit test within the OpenTelemetry C++ SDK trace tests directory. ```console bazel build //sdk/test/trace:tracer_provider_test ``` ```console bazel-bin/sdk/test/trace/tracer_provider_test ``` -------------------------------- ### Show git diff for CMakeLists.txt update Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/maintaining-dependencies.md Example of a git diff illustrating the version update for opentelemetry-proto in the CMake configuration. ```shell [malff@malff-desktop opentelemetry-cpp]$ git diff cmake/opentelemetry-proto.cmake diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 19516c3b..dd6213c1 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -49,7 +49,7 @@ else() "opentelemetry-proto=[ \t]*([A-Za-z0-9_\.\-]+)") set(opentelemetry-proto "${CMAKE_MATCH_1}") else() - set(opentelemetry-proto "v1.3.1") + set(opentelemetry-proto "v1.3.2") endif() unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) endif() ``` -------------------------------- ### Obtain a Tracer Provider and Tracer Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/api/GettingStarted.md Acquire a TracerProvider, which is typically a singleton provided by the SDK, and then get a Tracer instance for a specific library. If no SDK is used, a no-op implementation is provided. ```cpp auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("foo_library", "1.0.0"); ``` -------------------------------- ### Link API, SDK, and OTLP gRPC exporter to an application Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md Example CMakeLists.txt for an application that requires API, SDK, and OTLP gRPC exporter components from opentelemetry-cpp. ```cmake # foo_app/CMakeLists.txt find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api sdk exporters_otlp_grpc) add_executable(foo_app main.cpp) target_link_libraries(foo_app PRIVATE foo_lib opentelemetry-cpp::api opentelemetry-cpp::trace opentelemetry-cpp::otlp_grpc_exporter ) ``` -------------------------------- ### CMakeLists.txt for Unit Tests Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/google-test.md Example CMakeLists.txt configuration for defining and linking Google Tests. This snippet shows how to add executables for tests and benchmarks, linking necessary libraries. ```cmake foreach( testname tracer_provider_test span_data_test simple_processor_test tracer_test always_off_sampler_test always_on_sampler_test parent_or_else_sampler_test probability_sampler_test batch_span_processor_test attribute_utils_test) add_executable(${testname} "${testname}.cc") target_link_libraries( ${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common opentelemetry_trace) gtest_add_tests(TARGET ${testname} TEST_PREFIX trace. TEST_LIST ${testname}) endforeach() add_executable(sampler_benchmark sampler_benchmark.cc) target_link_libraries(sampler_benchmark benchmark::benchmark ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace) ``` -------------------------------- ### Symbol Reference Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/abi-version-policy.md Demonstrates the fully qualified symbol name generated by the compiler for the fictitious API, highlighting potential conflicts. ```cpp opentelemetry::common::OtelUtil::DoSomething() ``` -------------------------------- ### Create TracerShim from Global Config Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/opentracing-shim/README.md Initialize the TracerShim using the global OpenTelemetry configuration. Use this when you want to leverage the default OpenTelemetry setup. ```cpp auto tracer_shim = TracerShim::createTracerShim(); ``` -------------------------------- ### Configure Include Directories for Builder Utils Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/exporters/otlp/CMakeLists.txt Configures public include directories for the opentelemetry_exporter_otlp_builder_utils library, making its headers available during build and installation. ```cmake target_include_directories( opentelemetry_exporter_otlp_builder_utils PUBLIC "$" "$") ``` -------------------------------- ### Run Zipkin Server with Docker Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/zipkin/README.md Use this command to quickly start a Zipkin server locally using Docker. It exposes the Zipkin UI and API on port 9411. ```console docker run -d -p 9411:9411 openzipkin/zipkin ``` -------------------------------- ### Generate pkgconfig for OTLP Builder Utils Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/exporters/otlp/CMakeLists.txt Generates pkgconfig file for the opentelemetry_exporter_otlp_builder_utils library if installation is enabled. This provides metadata for consumers. ```cmake opentelemetry_add_pkgconfig( exporter_otlp_builder_utils "OpenTelemetry OTLP - Builder Utils" "Common utilities for OTLP exporter builders." "opentelemetry_otlp_recordable") ``` -------------------------------- ### Configure Include Directories for Shim Library Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/opentracing-shim/CMakeLists.txt Configures public include directories for the opentelemetry_opentracing_shim library, specifying build and install interfaces. ```cmake target_include_directories( opentelemetry_opentracing_shim PUBLIC "$" "$") ``` -------------------------------- ### Generate pkgconfig for OTLP Recordable Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/exporters/otlp/CMakeLists.txt Generates pkgconfig file for the opentelemetry_otlp_recordable library if installation is enabled. This helps other projects find and use the library. ```cmake opentelemetry_add_pkgconfig( otlp_recordable "OpenTelemetry OTLP - Recordable" "OTLP recordable implementation for spans, metrics, and logs." "opentelemetry_trace opentelemetry_metrics opentelemetry_logs opentelemetry_resources") ``` -------------------------------- ### CMakeLists.txt for Tracer Configurator Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/tracer_configurator/CMakeLists.txt Configures the build for the tracer configurator example. It defines the executable, links necessary OpenTelemetry libraries, and sets up a test if testing is enabled. ```cmake # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 add_executable(example_tracer_configurator main.cc) target_link_libraries( example_tracer_configurator PRIVATE opentelemetry-cpp::trace opentelemetry-cpp::ostream_span_exporter) if(BUILD_TESTING) add_test(NAME examples.tracer_configurator COMMAND "$") endif() ``` -------------------------------- ### Build Environment Carrier Executable (Non-Windows) Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/environment_carrier/CMakeLists.txt Configures the build for the environment carrier example on non-Windows systems. It adds the executable and links necessary OpenTelemetry libraries. ```cmake if(NOT WIN32) add_executable(example_environment_carrier main.cc) if(DEFINED OPENTELEMETRY_BUILD_DLL) target_compile_definitions(example_environment_carrier PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL) target_link_libraries(example_environment_carrier PRIVATE opentelemetry-cpp::opentelemetry_cpp) else() target_link_libraries( example_environment_carrier PRIVATE opentelemetry-cpp::trace opentelemetry-cpp::ostream_span_exporter) endif() if(BUILD_TESTING) add_test(NAME examples.environment_carrier COMMAND "$") endif() endif() ``` -------------------------------- ### Configure Test Executable Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/package_test/CMakeLists.txt Configures the main test executable 'full_test'. It adds source files for each installed component and links against the OpenTelemetry C++ libraries and Google Test. ```cmake add_executable(full_test) ``` ```cmake foreach(component IN LISTS INSTALL_TEST_COMPONENTS) message(STATUS "Adding test source for component ${component}") target_sources(full_test PRIVATE "${INSTALL_TEST_SRC_DIR}/test_${component}.cc") endforeach() ``` ```cmake target_include_directories(full_test PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS}) ``` ```cmake target_link_libraries(full_test PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES} GTest::gtest GTest::gtest_main) ``` ```cmake gtest_discover_tests(full_test) ``` -------------------------------- ### Add Test for Multi-Processor Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/multi_processor/CMakeLists.txt Conditionally adds a test for the multi-processor example if testing is enabled. The test executes the built example executable. ```cmake if(BUILD_TESTING) add_test(NAME examples.multi_processor COMMAND "$") endif() ``` -------------------------------- ### Option for Installing OpenTelemetry Targets Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/CMakeLists.txt A boolean option to control whether OpenTelemetry targets should be installed. ```cmake option(OPENTELEMETRY_INSTALL "Whether to install opentelemetry targets" ${OPENTELEMETRY_INSTALL_default}) ``` -------------------------------- ### Initialize Zipkin Exporter in C++ Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/exporters/zipkin/README.md Set up the Zipkin exporter by configuring endpoint and service name options. This example demonstrates creating a Zipkin exporter, a simple span processor, and a tracer provider, then setting it as the global provider. ```cpp opentelemetry::exporter::zipkin::ZipkinExporterOptions options; options.endpoint = "http://localhost:9411/api/v2/spans"; options.service_name = "my_service"; auto exporter = std::unique_ptr( new opentelemetry::exporter::zipkin::ZipkinExporter(options)); auto processor = std::shared_ptr( new sdktrace::SimpleSpanProcessor(std::move(exporter))); auto provider = nostd::shared_ptr( new sdktrace::TracerProvider(processor, opentelemetry::sdk::resource::Resource::Create({}), std::make_shared())); // Set the global trace provider opentelemetry::trace::Provider::SetTracerProvider(provider); ``` -------------------------------- ### Initialize TracerProvider with SDK Configurations Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/sdk/GettingStarted.md Demonstrates creating a TracerProvider instance by directly providing SDK configurations such as span processors, resource, and samplers. ```cpp // Create using SDK configurations as parameter auto tracer_provider = nostd::shared_ptr (std::move(simple_processor), resource, std::move(always_on_sampler)); ``` -------------------------------- ### Add Test Target for Example Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/logs_simple/CMakeLists.txt Conditionally adds a CTest target to run the example executable if testing is enabled. ```cmake if(BUILD_TESTING) add_test(NAME examples.logs_simple COMMAND "$") endif() ``` -------------------------------- ### Configure Build with CMake Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md Navigate to the cloned repository and create the CMake build configuration. This step prepares the build environment for the library. ```console $ cd opentelemetry-cpp $ mkdir build && cd build && cmake .. -- The C compiler identification is GNU 9.3.0 -- The CXX compiler identification is GNU 9.3.0 ... -- Configuring done -- Generating done -- Build files have been written to: /home//source/opentelemetry-cpp/build $ ``` -------------------------------- ### Validate Installed Components Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/CMakeLists.txt Checks if the components specified in INSTALL_TEST_COMPONENTS are valid installed components of opentelemetry-cpp. It ensures that only available components are tested. ```cmake if(NOT INSTALL_TEST_COMPONENTS) message( STATUS "INSTALL_TEST_COMPONENTS is not set. Setting to OPENTELEMETRY_CPP_COMPONENTS_INSTALLED" ) set(INSTALL_TEST_COMPONENTS ${OPENTELEMETRY_CPP_COMPONENTS_INSTALLED}) else() set(COMPONENTS_ARE_VALID TRUE) foreach(component ${INSTALL_TEST_COMPONENTS}) if(NOT component IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED) message( ERROR " Component ${component} is not an installed opentelemetry-cpp component" ) set(COMPONENTS_ARE_VALID FALSE) endif() endforeach() if(NOT COMPONENTS_ARE_VALID) message(FATAL_ERROR "INSTALL_TEST_COMPONENTS contains invalid components") endif() endif() ``` -------------------------------- ### Initialize OpenTelemetry C++ Exporters Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/sdk/GettingStarted.md Demonstrates how to initialize various OpenTelemetry C++ tracing exporters, including logging, in-memory, Zipkin, OTLP gRPC, and OTLP HTTP. Ensure necessary configurations like endpoints and service names are set. ```cpp //namespace alias used in sample code here. namespace sdktrace = opentelemetry::sdk::trace; // logging exporter auto ostream_exporter = std::unique_ptr(new opentelemetry::exporter::trace::OStreamSpanExporter); // memory exporter auto memory_exporter = std::unique_ptr(new opentelemetry::exporter::memory::InMemorySpanExporter); // zipkin exporter opentelemetry::exporter::zipkin::ZipkinExporterOptions opts; opts.endpoint = "http://localhost:9411/api/v2/spans" ; // or export OTEL_EXPORTER_ZIPKIN_ENDPOINT="..." opts.service_name = "default_service" ; auto zipkin_exporter = std::unique_ptr(new opentelemetry::exporter::zipkin::ZipkinExporter(opts)); // otlp grpc exporter opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; opts.endpoint = "localhost:4317"; opts.use_ssl_credentials = true; opts.ssl_credentials_cacert_as_string = "ssl-certificate"; auto otlp_grpc_exporter = std::unique_ptr(new opentelemetry::exporter::otlp::OtlpGrpcExporter(opts)); // otlp http exporter opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts; opts.url = "http://localhost:4318/v1/traces"; auto otlp_http_exporter = std::unique_ptr(new opentelemetry::exporter::otlp::OtlpHttpExporter(opts)); ``` -------------------------------- ### Clone and Build OpenTelemetry C++ SDK Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vs2019.md This sequence of commands clones the OpenTelemetry C++ SDK repository recursively, sets up the build tools and dependencies, and then builds the SDK. The setup step may take several minutes as it compiles dependencies. ```console git clone --recursive https://github.com/open-telemetry/opentelemetry-cpp cd opentelemetry-cpp tools\setup-buildtools.cmd tools\build.cmd ``` -------------------------------- ### Start a Span Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/api/GettingStarted.md Create a new span with a given name and set its start time to the current time. Additional data can be added to enrich the span. ```cpp auto span = tracer->StartSpan("HandleRequest"); ``` -------------------------------- ### Create TracerContext for SDK Configuration Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/sdk/GettingStarted.md Shows how to create a TracerContext, which holds shared SDK configurations like processors, resource, and samplers. ```cpp auto tracer_context = std::make_shared (std::move(multi_processor), resource, std::move(always_on_sampler)); ``` -------------------------------- ### Find OpenTelemetry C++ Package Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/CMakeLists.txt Finds the installed OpenTelemetry C++ package using CMake's find_package command. This is required to access installed components. ```cmake find_package(opentelemetry-cpp CONFIG REQUIRED) ``` -------------------------------- ### Configure OTLP HTTP Client for SSL Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/testing-with-ssl.md Configure environment variables to point an OTLP HTTP client to an SSL-enabled endpoint and specify certificate files. Then, run the `example_otlp_http` client. ```shell shell> export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://localhost:4318/v1/traces shell> export OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE=ca.pem shell> export OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE=client_cert.pem shell> export OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY=client_cert-key.pem shell> example_otlp_http ``` -------------------------------- ### Initialize TracerProvider with TracerContext Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/sdk/GettingStarted.md Illustrates creating a TracerProvider instance using an existing TracerContext object. ```cpp // Created using `TracerContext` instance auto tracer_provider = nostd::shared_ptr (new sdktrace::TracerProvider(tracer_context)); ``` -------------------------------- ### Install OpenTelemetry C++ on Alpine Linux Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md For Alpine Linux users, install the OpenTelemetry C++ development packages from the testing repository using the apk add command. Ensure the testing repository is added to your sources. ```console apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing opentelemetry-cpp-dev ``` -------------------------------- ### Initialize MeterProvider and Add Reader Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/metrics_simple/README.md Creates a MeterProvider and adds the configured metric reader to it. This provider will be used to obtain Meter objects. ```cpp auto provider = std::shared_ptr(new metric_sdk::MeterProvider()); auto p = std::static_pointer_cast(provider); p->AddMetricReader(std::move(reader)); ``` -------------------------------- ### CMakeLists.txt for OTLP Exporters Common Install Test Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/component_tests/exporters_otlp_common/CMakeLists.txt Configures the build for testing the installed opentelemetry-cpp exporters_otlp_common component. It finds the necessary packages, defines the test executable, and links required libraries including Google Test. ```cmake cmake_minimum_required(VERSION 3.16) project(opentelemetry-cpp-exporters-otlp-common-install-test LANGUAGES CXX) find_package(opentelemetry-cpp REQUIRED COMPONENTS exporters_otlp_common) if(NOT TARGET protobuf::libprotobuf) message(FATAL_ERROR "protobuf::libprotobuf target not found") endif() find_package(GTest CONFIG REQUIRED) include(GoogleTest) add_executable(exporters_otlp_common_test ${INSTALL_TEST_SRC_DIR}/test_exporters_otlp_common.cc) target_link_libraries( exporters_otlp_common_test PRIVATE opentelemetry-cpp::proto opentelemetry-cpp::otlp_recordable GTest::gtest GTest::gtest_main) gtest_discover_tests(exporters_otlp_common_test) ``` -------------------------------- ### Create client and server executables Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/grpc/CMakeLists.txt This loop creates 'client' and 'server' executables, each compiled from their respective .cc files. They are linked against the generated proto library and the OpenTelemetry ostream span exporter. ```cmake foreach(_target client server) add_executable(${_target} "${_target}.cc") target_link_libraries( ${_target} PRIVATE example_grpc_proto opentelemetry-cpp::ostream_span_exporter) endforeach() ``` -------------------------------- ### Extract OpenTelemetry C++ Installation from Docker Image Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docker/README.md These commands create a temporary Docker container, copy the installed OpenTelemetry C++ files to the current directory, and then remove the container. This is useful for obtaining the built library artifacts. ```bash docker create -ti --name otel otel-cpp-alpine-latest bash docker cp otel:/opt/opentelemetry-cpp-install ./ docker rm -f otel ``` -------------------------------- ### Lint Shell Scripts Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/CONTRIBUTING.md Install and run shellcheck to check for errors in shell scripts. ```sh shellcheck --severity=error .sh ``` -------------------------------- ### Initialize OpenTelemetry C++ Samplers Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/sdk/GettingStarted.md Demonstrates how to initialize instances of the four built-in samplers: AlwaysOnSampler, AlwaysOffSampler, ParentBasedSampler, and TraceIdRatioBasedSampler. ```cpp //AlwaysOnSampler auto always_on_sampler = std::unique_ptr (new sdktrace::AlwaysOnSampler); //AlwaysOffSampler auto always_off_sampler = std::unique_ptr (new sdktrace::AlwaysOffSampler); //ParentBasedSampler auto parent_based_sampler = std::unique_ptr (new sdktrace::ParentBasedSampler); //TraceIdRatioBasedSampler - Sample 50% generated spans double ratio = 0.5; auto always_off_sampler = std::unique_ptr (new sdktrace::TraceIdRatioBasedSampler(ratio)); ``` -------------------------------- ### Link API component to a library Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md Example CMakeLists.txt for a library that only requires the opentelemetry-cpp API component. ```cmake # foo_lib/CMakeLists.txt find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api) add_library(foo_lib foo.cpp) target_link_libraries(foo_lib PRIVATE opentelemetry-cpp::api) ``` -------------------------------- ### Lint Markdown Files Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/CONTRIBUTING.md Install and run markdownlint-cli to check for formatting issues in Markdown files. ```sh markdownlint . ``` -------------------------------- ### Add Example to CTest Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/metrics_simple/CMakeLists.txt Adds the built metrics_ostream_example executable as a test case to CTest if testing is enabled. ```cmake if(BUILD_TESTING) add_test(NAME examples.metrics_simple COMMAND "$") endif() ``` -------------------------------- ### Run Pre-Release Script Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/RELEASING.md Execute the pre-release script to create a pre-release branch and update the changelog. Replace `` with the desired version tag. ```sh ./buildscripts/pre_release.sh -t ``` -------------------------------- ### Create library from generated proto code Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/grpc/CMakeLists.txt This command creates a CMake library named 'example_grpc_proto' from the generated C++ source and header files. It also disables static analysis tools on the generated code and sets include directories. ```cmake add_library(example_grpc_proto ${example_grpc_srcs} ${example_grpc_hdrs} ${example_proto_srcs} ${example_proto_hdrs}) ``` ```cmake set_target_properties(example_grpc_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "" CXX_CLANG_TIDY "") ``` ```cmake target_include_directories( example_grpc_proto PUBLIC "$") ``` -------------------------------- ### Run Full Package Test Executable Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/CMakeLists.txt Executes the test suite for the full OpenTelemetry C++ package installation. ```cmake add_test(NAME full-package-run-test COMMAND ${CMAKE_BINARY_DIR}/build-full-package-test/full_test) ``` -------------------------------- ### Build All Targets with Bazel Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md Navigate to the cloned repository directory and build all targets using Bazel. This command downloads dependencies and compiles the source code. ```bash cd opentelemetry-cpp bazel build //... ``` -------------------------------- ### Build Full Package Test Executable Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/install/test/cmake/CMakeLists.txt Builds the test executable for the full OpenTelemetry C++ package installation. ```cmake add_test(NAME full-package-build-test COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/build-full-package-test --parallel) ``` -------------------------------- ### Run All Bazel Tests Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md After building, run all the built Bazel tests using the `bazel test //...` command. ```bash bazel test //... ``` -------------------------------- ### API Definition using OPENTELEMETRY_BEGIN_NAMESPACE Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/abi-version-policy.md Demonstrates how to abstract the namespace definition using macros for cleaner code and easier ABI version management. ```cpp #define OPENTELEMETRY_ABI_VERSION_NO 1 OPENTELEMETRY_BEGIN_NAMESPACE { namespace common { class OtelUtil { virtual void DoSomething() = 0; }; } } OPENTELEMETRY_END_NAMESPACE ``` -------------------------------- ### Get Latest Commit Hash Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/RELEASING.md Retrieve the hash of the latest commit on the master branch after a pull request has been merged. ```sh git show -s --format=%H ``` -------------------------------- ### SDK MeterProvider GetMeter Implementation Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/abi-version-policy.md Provides the SDK implementation for MeterProvider::GetMeter(), showing how to handle new parameters for ABI v2 or use default values for ABI v1. ```cpp nostd::shared_ptr MeterProvider::GetMeter( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url #if OPENTELEMETRY_ABI_VERSION_NO >= 2 , const opentelemetry::common::KeyValueIterable *attributes #endif ) noexcept { #if OPENTELEMETRY_ABI_VERSION_NO < 2 const opentelemetry::common::KeyValueIterable *attributes = nullptr; #endif /* common implementation, use attributes */ } ``` -------------------------------- ### Show git diff for third_party_release update Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/maintaining-dependencies.md Example of a git diff showing the change in the opentelemetry-proto version in the third_party_release file. ```shell [malff@malff-desktop opentelemetry-cpp]$ git diff third_party_release diff --git a/third_party_release b/third_party_release index 0bbf67f3..7362473f 100644 --- a/third_party_release +++ b/third_party_release @@ -19,7 +19,7 @@ benchmark=v1.8.3 googletest=1.14.0 ms-gsl=v3.1.0-67-g6f45293 nlohmann-json=v3.11.3 -opentelemetry-proto=v1.3.1 +opentelemetry-proto=v1.3.2 opentracing-cpp=v1.6.0 prometheus-cpp=v1.2.4 vcpkg=2024.02.14 ``` -------------------------------- ### Initialize OpenTelemetry C++ Span Processors Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/sdk/GettingStarted.md Demonstrates the initialization of SimpleSpanProcessor, BatchSpanProcessor, and MultiSpanProcessor. Ensure an exporter is available before initializing processors. ```cpp // simple processor auto simple_processor = std::unique_ptr( new sdktrace::SimpleSpanProcessor(std::move(ostream_exporter))); // batch processor sdktrace::BatchSpanProcessorOptions options{}; auto batch_processor = std::unique_ptr( new sdktrace::BatchSpanProcessor(std::move(memory_exporter), options)); // multi-processor std::vector> processors{std::move(simple_processor), std::move(batch_processor)}; auto multi_processor = std::unique_ptr( new sdktrace::MultiSpanProcessor(std::move(processors)); ``` -------------------------------- ### Server Console Output Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/grpc/README.md Example output from the server's console exporter, detailing the server-side span for a gRPC request. ```json { name : GreeterService/Greet trace_id : f5d16f8399be0d2c6b39d992634ffdbb span_id : 1e8a7d2d46e08573 tracestate : parent_span_id: 9c79a2dd744d7d2d start : 1622603339923163800 duration : 76400 description : span kind : Server status : Ok attributes : rpc.grpc.status_code: 0 rpc.method: Greet rpc.service: GreeterService rpc.system: grpc events : { name : Processing client attributes timestamp : 1622603339923180800 attributes : } { name : Response sent to client timestamp : 1622603339923233700 attributes : } links : } ``` -------------------------------- ### Client Console Output Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/grpc/README.md Example output from the client's console exporter, showing span details for a gRPC request. ```json { name : GreeterClient/Greet trace_id : f5d16f8399be0d2c6b39d992634ffdbb span_id : 9c79a2dd744d7d2d tracestate : parent_span_id: 0000000000000000 start : 1622603339918985700 duration : 4960500 description : span kind : Client status : Ok attributes : rpc.grpc.status_code: 0 net.peer.port: 8080 net.peer.ip: 0.0.0.0 rpc.method: Greet rpc.service: grpc-example.GreetService rpc.system: grpc events : } ``` -------------------------------- ### Create and Use OpenTelemetry C++ Resource Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/public/sdk/GettingStarted.md Shows how to create a Resource with custom attributes and retrieve its attributes. The SDK automatically adds telemetry.sdk.* attributes. ```cpp auto resource_attributes = opentelemetry::sdk::resource::ResourceAttributes { {"service.name", "shoppingcart"}, {"service.instance.id", "instance-12"} }; auto resource = opentelemetry::sdk::resource::Resource::Create(resource_attributes); auto received_attributes = resource.GetAttributes(); // received_attributes contains // - service.name = shoppingcart // - service.instance.id = instance-12 // - telemetry.sdk.name = opentelemetry // - telemetry.sdk.language = cpp // - telemetry.sdk.version = ``` -------------------------------- ### Build and Run Google Test with Bazel Source: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/google-test.md Commands to build and execute a specific Bazel unit test target. The first command builds the test, and the second runs the compiled binary. ```console bazel build //path/to/package:target-name ``` ```console bazel-bin/path/to/package/target-name ```