]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Copyright (c) 2018 Uber Technologies, Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | #include <cassert> | |
17 | #include <cstring> | |
18 | #include <system_error> | |
19 | ||
20 | #include <opentracing/dynamic_load.h> | |
21 | ||
22 | #include "jaegertracing/Tracer.h" | |
23 | #include "jaegertracing/TracerFactory.h" | |
24 | ||
25 | static int makeTracerFactory(const char* opentracingVersion, | |
26 | const char* opentracingABIVersion, | |
27 | const void** errorCategory, | |
28 | void* errorMessage, | |
29 | void** tracerFactory) | |
30 | { | |
31 | assert(errorCategory != nullptr); | |
32 | assert(tracerFactory != nullptr); | |
33 | #ifndef JAEGERTRACING_WITH_YAML_CPP | |
34 | *errorCategory = | |
35 | static_cast<const void*>(&opentracing::dynamic_load_error_category()); | |
36 | return opentracing::dynamic_load_not_supported_error.value(); | |
37 | #endif | |
38 | if (std::strcmp(opentracingABIVersion, OPENTRACING_ABI_VERSION) != 0) { | |
39 | *errorCategory = static_cast<const void*>( | |
40 | &opentracing::dynamic_load_error_category()); | |
41 | return opentracing::incompatible_library_versions_error.value(); | |
42 | } | |
43 | ||
44 | const auto jaegerTracerFactory = new (std::nothrow) jaegertracing::TracerFactory(true); | |
45 | *tracerFactory = jaegerTracerFactory; | |
46 | if (*tracerFactory == nullptr) { | |
47 | *errorCategory = static_cast<const void*>(&std::generic_category()); | |
48 | return static_cast<int>(std::errc::not_enough_memory); | |
49 | } | |
50 | ||
51 | return 0; | |
52 | } | |
53 | ||
54 | OPENTRACING_DECLARE_IMPL_FACTORY(makeTracerFactory) |