| 142 | }; |
| 143 | |
| 144 | int main(int argc, char **argv) { |
| 145 | try { |
| 146 | std::string url("127.0.0.1:5672/examples"); |
| 147 | |
| 148 | // 1. Initialize the exporter and the provider. |
| 149 | // 2. Set the global trace provider. |
| 150 | // 3. Call proton::initOpenTelemetryTracer(). |
| 151 | |
| 152 | // Initialize otlp http Exporter |
| 153 | opentelemetry::exporter::otlp::OtlpHttpExporterOptions options; |
| 154 | options.url = "localhost:4318"; |
| 155 | auto exporter = std::unique_ptr<opentelemetry::sdk::trace::SpanExporter>(new opentelemetry::exporter::otlp::OtlpHttpExporter(options)); |
| 156 | |
| 157 | // Set service-name |
| 158 | auto resource_attributes = opentelemetry::sdk::resource::ResourceAttributes |
| 159 | { |
| 160 | {"service.name", "qpid-example-client"} |
| 161 | }; |
| 162 | |
| 163 | // Creation of the resource for associating it with telemetry |
| 164 | auto resource = opentelemetry::sdk::resource::Resource::Create(resource_attributes); |
| 165 | |
| 166 | auto processor = std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor>( |
| 167 | new opentelemetry::sdk::trace::SimpleSpanProcessor(std::move(exporter))); |
| 168 | provider = opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>( |
| 169 | new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource)); |
| 170 | |
| 171 | // Set the global trace provider |
| 172 | opentelemetry::trace::Provider::SetTracerProvider(provider); |
| 173 | |
| 174 | // Enable tracing in proton cpp |
| 175 | proton::initOpenTelemetryTracer(); |
| 176 | |
| 177 | // Sending 2 messages to the server. |
| 178 | std::vector<std::string> requests; |
| 179 | requests.push_back("Two roads diverged in a wood."); |
| 180 | requests.push_back("I took the one less traveled by."); |
| 181 | |
| 182 | client c(url, requests); |
| 183 | |
| 184 | proton::container(c).run(); |
| 185 | |
| 186 | return 0; |
| 187 | } catch (const std::exception& e) { |
| 188 | std::cerr << e.what() << std::endl; |
| 189 | } |
| 190 | |
| 191 | return 1; |
| 192 | } |
nothing calls this directly
no test coverage detected