Skip to content

Commit

Permalink
Merge branch 'sdk_docs_impl' of github.com:lalitb/opentelemetry-cpp i…
Browse files Browse the repository at this point in the history
…nto sdk_docs_impl
  • Loading branch information
lalitb committed Aug 10, 2021
2 parents de60f5b + 88f932f commit a43028d
Show file tree
Hide file tree
Showing 53 changed files with 989 additions and 342 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
./ci/do_ci.sh cmake.abseil.test
cmake_gcc_48_test:
name: CMake gcc 4.8
name: CMake gcc 4.8 (without otlp exporter)
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand All @@ -59,6 +59,29 @@ jobs:
CC: /usr/bin/gcc-4.8
CXX: /usr/bin/g++-4.8

cmake_gcc_48_otlp_exporter_test:
name: CMake gcc 4.8 (with otlp exporter)
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: setup
run: |
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_gcc48.sh
- name: setup cmake
run: |
sudo CC=/usr/bin/gcc-4.8 CXX=/usr/bin/g++-4.8 ./ci/setup_cmake.sh
- name: setup grpc
run: |
sudo CC=/usr/bin/gcc-4.8 CXX=/usr/bin/g++-4.8 ./ci/setup_grpc.sh -v 4.8
- name: run tests
run: ./ci/do_ci.sh cmake.legacy.exporter.otprotocol.test
env:
CC: /usr/bin/gcc-4.8
CXX: /usr/bin/g++-4.8

cmake_test_cxx20:
name: CMake C++20 test
runs-on: ubuntu-20.04
Expand Down
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,27 @@ Increment the:

## [Unreleased]

* [BUILD] Allow to use local GSL
## [1.0.0-rc4] 2021-08-04

* [EXPORTER] `BREAKING CHANGE` Fix default HTTP port for OTLP HTTP Exporter ([#939](https://github.com/open-telemetry/opentelemetry-cpp/pull/939))
* [API] Fix timeout calculation for Tracer::Flush() and Tracer::Close() ([#937](https://github.com/open-telemetry/opentelemetry-cpp/pull/937))
* [API] Fix for Stack::Resize that new_capacity is not assigned to capacity_ ([#934](https://github.com/open-telemetry/opentelemetry-cpp/pull/934))
* [SDK] Fix race condition in circular buffer simulation test ([#931](https://github.com/open-telemetry/opentelemetry-cpp/pull/931))
* [EXPORTER] Fix error logging in Jaeger Exporter ([#930](https://github.com/open-telemetry/opentelemetry-cpp/pull/930))
* [BUILD] Use latest grpc version (v1.39.0) for cmake build of otlp exporter ([#927](https://github.com/open-telemetry/opentelemetry-cpp/pull/927))
* [EXPORTER] Add Jaeger Thrift HTTP exporter ([#926](https://github.com/open-telemetry/opentelemetry-cpp/pull/926))
* [SDK] Move env-var read logic to common dir, and optional reading of env-var ([#924](https://github.com/open-telemetry/opentelemetry-cpp/pull/924))
* [EXPORTER] Remove recordable header from CMake install rules for exporters ([#923](https://github.com/open-telemetry/opentelemetry-cpp/pull/923))
* [EXPORTER] `BREAKING CHANGE` Rename Recordable to JaegerRecordable in Jaeger exporter ([#919](https://github.com/open-telemetry/opentelemetry-cpp/pull/919))
* [EXPORTER] `BREAKING CHANGE` Rename Jaeger exporter target ([#918](https://github.com/open-telemetry/opentelemetry-cpp/pull/918))
* [EXPORTER] Add Zipkin exporter example ([#917](https://github.com/open-telemetry/opentelemetry-cpp/pull/917))
* [EXPORTER] Bazel build for Zipkin exorter ([#916](https://github.com/open-telemetry/opentelemetry-cpp/pull/916))
* [BUILD] Allow to use local GSL ([#915](https://github.com/open-telemetry/opentelemetry-cpp/pull/915))
* [DOCS] Document vcpkg toolchain configuration ([#913](https://github.com/open-telemetry/opentelemetry-cpp/pull/913))
* [SDK] Fix for resource deletion after tracer provider shutdown ([#911](https://github.com/open-telemetry/opentelemetry-cpp/pull/911))
* [BUILD] Add bazel build for grpc example ([#910](https://github.com/open-telemetry/opentelemetry-cpp/pull/910))
* [EXPORTER] Add resource and instrumentation library support for OStreamSpanExporter ([#906](https://github.com/open-telemetry/opentelemetry-cpp/pull/906))
* [API] Adding semantic-convention attributes for trace ([#868](https://github.com/open-telemetry/opentelemetry-cpp/pull/868))

## [1.0.0-rc3] 2021-07-12

Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ option(WITH_ELASTICSEARCH

option(WITH_JAEGER "Whether to include the Jaeger exporter" OFF)

option(WITH_NO_GETENV "Whether the platform supports environment variables" OFF)

option(BUILD_TESTING "Whether to enable tests" ON)

if(WITH_NO_GENENV)
add_definitions(-DNO_GETENV)
endif()

if(WIN32)
add_definitions(-DNOMINMAX)
if(BUILD_TESTING)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ Approvers
* [Josh Suereth](https://github.com/jsuereth), Google
* [Max Golovanov](https://github.com/maxgolov), Microsoft
* [Ryan Burn](https://github.com/rnburn), Lightstep
* [Tom Tan](https://github.com/ThomsonTan), Microsoft

*Find more about the approver role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).*
Expand All @@ -89,6 +88,7 @@ Maintainers
* [Emil Mikulic](https://github.com/g-easy), Google
* [Lalit Kumar Bhasin](https://github.com/lalitb), Microsoft
* [Reiley Yang](https://github.com/reyang), Microsoft
* [Tom Tan](https://github.com/ThomsonTan), Microsoft

*Find more about the maintainer role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).*
Expand Down
3 changes: 2 additions & 1 deletion api/include/opentelemetry/context/runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ class ThreadLocalContextStorage : public RuntimeContextStorage
}
delete[] base_;
}
base_ = temp;
base_ = temp;
capacity_ = new_capacity;
}

~Stack() noexcept { delete[] base_; }
Expand Down
189 changes: 189 additions & 0 deletions api/include/opentelemetry/trace/semantic_conventions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/common/string_util.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{

#define OTEL_CPP_GET_ATTR(name) attr(OTEL_CPP_CONST_HASHCODE(name))

/**
* Stores the Constants for semantic kAttribute names outlined by the OpenTelemetry specifications.
* <see
* href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/README.md"/>.
*/
static const struct
{
uint32_t attribute_id;
const char *attribute_key;
} attribute_ids[] = {
// The set of constants matches the specification as of this commit.
// https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/trace/semantic_conventions
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/exceptions.md

// General network connection attributes
{OTEL_CPP_CONST_HASHCODE(AttrNetTransport), "net.transport"},
{OTEL_CPP_CONST_HASHCODE(AttrNetPeerIp), "net.peer.ip"},
{OTEL_CPP_CONST_HASHCODE(AttrNetPeerPort), "net.peer.port"},
{OTEL_CPP_CONST_HASHCODE(AttrNetPeerName), "net.peer.name"},
{OTEL_CPP_CONST_HASHCODE(AttrNetHostIp), "net.host.ip"},
{OTEL_CPP_CONST_HASHCODE(AttrNetHostPort), "net.host.port"},
{OTEL_CPP_CONST_HASHCODE(AttrNetHostName), "net.host.name"},

// General identity attributes
{OTEL_CPP_CONST_HASHCODE(AttrEnduserId), "enduser.id"},
{OTEL_CPP_CONST_HASHCODE(AttrEnduserRole), "enduser.role"},
{OTEL_CPP_CONST_HASHCODE(AttrEnduserScope), "enduser.scope"},

// General remote service attributes
{OTEL_CPP_CONST_HASHCODE(AttrPeerService), "peer.service"},

// General thread attributes
{OTEL_CPP_CONST_HASHCODE(AttrThreadId), "thread.id"},
{OTEL_CPP_CONST_HASHCODE(AttrThreadName), "thread.name"},

// Source Code Attributes
{OTEL_CPP_CONST_HASHCODE(AttrCodeFunction), "code.function"},
{OTEL_CPP_CONST_HASHCODE(AttrCodeNamespace), "code.namespace"},
{OTEL_CPP_CONST_HASHCODE(AttrCodeFilepath), "code.filepath"},
{OTEL_CPP_CONST_HASHCODE(AttrCodeLineno), "code.lineno"},

// Http Span Common Attributes
{OTEL_CPP_CONST_HASHCODE(AttrHttpMethod), "http.method"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpUrl), "http.url"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpTarget), "http.target"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpHost), "http.host"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpScheme), "http.scheme"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpStatusCode), "http.status_code"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpFlavor), "http.flavor"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpUserAgent), "http.user_agent"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpRequestContentLength), "http.request_content_length"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpRequestContentLengthUncompressed),
"http.request_content_length_uncompressed"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpResponseContentLength), "http.response_content_length"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpResponseContentLengthUncompressed),
"http.response_content_length_uncompressed"},

// HTTP Span Client Attributes
// One of the following combinations:
// - http.url
// - http.scheme, http.host, http.target
// - http.scheme, net.peer.name, net.peer.port, http.target
// - http.scheme, net.peer.ip, net.peer.port, http.target

// HTTP Span Server Attributes
// One of the following combinations:
// -http.scheme, http.host, http.target
// -http.scheme, http.server_name, net.host.port, http.target
// -http.scheme, net.host.name, net.host.port, http.target
// -http.url
{OTEL_CPP_CONST_HASHCODE(AttrHttpServerName), "http.server_name"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpRoute), "http.route"},
{OTEL_CPP_CONST_HASHCODE(AttrHttpClientIp), "http.client_ip"},

// DB: Connection-level attributes
{OTEL_CPP_CONST_HASHCODE(AttrDbSystem), "db.system"}, // other_sql, mssql, mysql...
{OTEL_CPP_CONST_HASHCODE(AttrDbConnectionString), "db.connection_string"},
{OTEL_CPP_CONST_HASHCODE(AttrDbUser), "db.user"},
// DB: Connection-level attributes for specific technologies
{OTEL_CPP_CONST_HASHCODE(AttrDbMssqlInstanceName), "db.mssql.instance_name"},
{OTEL_CPP_CONST_HASHCODE(AttrDbJdbcDriverClassname), "db.jdbc.driver_classname"},
// DB: Call-level attributes
{OTEL_CPP_CONST_HASHCODE(AttrDbName), "db.name"},
{OTEL_CPP_CONST_HASHCODE(AttrDbStatement), "db.statement"},
{OTEL_CPP_CONST_HASHCODE(AttrDbOperation), "db.operation"},
// DB: Call-level attributes for specific technologies
{OTEL_CPP_CONST_HASHCODE(AttrDbHbaseNamespace), "db.hbase.namespace"},
{OTEL_CPP_CONST_HASHCODE(AttrDbRedisDatabaseIndex), "db.redis.database_index"},
{OTEL_CPP_CONST_HASHCODE(AttrDbMongodbCollection), "db.mongodb.collection"},

// // DB: Call-level attributes for Cassandra for clarity
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraKeyspace), "db.cassandra.keyspace"},
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraPageSize), "db.cassandra.page_size"},
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraConsistencyLevel), "db.cassandra.consistency_level"},
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraTable), "db.cassandra.table"},
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraIdempotence), "db.cassandra.idempotence"},
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraSpeculativeExecutionCount),
"db.cassandra.speculative_execution_count"},
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraCoordinatorId), "db.cassandra.coordinator.id"},
{OTEL_CPP_CONST_HASHCODE(AttrDbCassandraCoordinatorDC), "db.cassandra.coordinator.dc"},

// Common RPC attributes
{OTEL_CPP_CONST_HASHCODE(AttrRpcSystem), "rpc.system"},
{OTEL_CPP_CONST_HASHCODE(AttrRpcService), "rpc.service"},
{OTEL_CPP_CONST_HASHCODE(AttrRpcMethod), "rpc.method"},
// gRPC attributes
{OTEL_CPP_CONST_HASHCODE(AttrRpcGrpcStatusCode), "rpc.grpc.status_code"},
// JSON-RPC attributes
{OTEL_CPP_CONST_HASHCODE(AttrRpcJsonrpcVersion), "rpc.jsonrpc.version"},
{OTEL_CPP_CONST_HASHCODE(AttrRpcJsonrpcRequestId), "rpc.jsonrpc.request_id"},
{OTEL_CPP_CONST_HASHCODE(AttrRpcJsonrpcErrorCode), "rpc.jsonrpc.error_code"},
{OTEL_CPP_CONST_HASHCODE(AttrRpcJsonrpcErrorMessage), "rpc.jsonrpc.error_message"},

// faas: General Attributes
{OTEL_CPP_CONST_HASHCODE(AttrFaasTrigger), "faas.trigger"},
{OTEL_CPP_CONST_HASHCODE(AttrFaasExecution), "faas.execution"},
// faas: incoming invocations
{OTEL_CPP_CONST_HASHCODE(AttrFaasColdStart), "faas.coldstart"},
// faas: outgoing invocations
{OTEL_CPP_CONST_HASHCODE(AttrFaasInvokedName), "faas.invoked_name"},
{OTEL_CPP_CONST_HASHCODE(AttrFaasInvokedProvider), "faas.invoked_provider"},
{OTEL_CPP_CONST_HASHCODE(AttrFaasInvokedRegion), "faas.invoked_region"},
// faas: datastore trigger
{OTEL_CPP_CONST_HASHCODE(AttrFaasDocumentCollection), "faas.document.collection"},
{OTEL_CPP_CONST_HASHCODE(AttrFaasDocumentOperation), "faas.document.operation"},
{OTEL_CPP_CONST_HASHCODE(AttrFaasDocumentTime), "faas.document.time"},
{OTEL_CPP_CONST_HASHCODE(AttrFaasDocumentName), "faas.document.name"},
// faas: timer trigger
{OTEL_CPP_CONST_HASHCODE(AttrFaasTime), "faas.time"},
{OTEL_CPP_CONST_HASHCODE(AttrFaasCron), "faas.cron"},

// messaging attributes
{OTEL_CPP_CONST_HASHCODE(AttrMessagingSystem), "messaging.system"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingDestination), "messaging.destination"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingDestinationKind), "messaging.destination_kind"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingTempDestination), "messaging.temp_destination"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingProtocol), "messaging.protocol"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingProtocolVersion), "messaging.protocol_version"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingUrl), "messaging.url"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingMessageId), "messaging.message_id"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingConversationId), "messaging.conversation_id"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingPayloadSize), "messaging.message_payload_size_bytes"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingPayloadCompressedSize),
"messaging.message_payload_compressed_size_bytes"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingOperation), "messaging.operation"},
// messaging attributes specific to messaging systems
{OTEL_CPP_CONST_HASHCODE(AttrMessagingRabbitMQRoutingKey), "messaging.rabbitmq.routing_key"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingKafkaMessageKey), "messaging.kafka.message_key"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingKafkaConsumerGroup), "messaging.kafka.consumer_group"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingKafkaClientId), "messaging.kafka.client_id"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingKafkaPartition), "messaging.kafka.partition"},
{OTEL_CPP_CONST_HASHCODE(AttrMessagingKafkaTombstone), "messaging.kafka.tombstone"},

// Exceptions attributes
{OTEL_CPP_CONST_HASHCODE(AttrExceptionType), "exception.type"},
{OTEL_CPP_CONST_HASHCODE(AttrExceptionMessage), "exception.message"},
{OTEL_CPP_CONST_HASHCODE(AttrExceptionStacktrace), "exception.stacktrace"},
{OTEL_CPP_CONST_HASHCODE(AttrExceptionEscapted), "exception.escaped"},
};
// function to generate hash code for semantic conventions attributes.

#define OTEL_CPP_TRACE_ATTRIBUTES_MAX (sizeof(attribute_ids) / sizeof(attribute_ids[0]))

inline const char *attr(uint32_t attr)
{
for (int i = 0; i < OTEL_CPP_TRACE_ATTRIBUTES_MAX; i++)
{
if (attribute_ids[i].attribute_id == attr)
return attribute_ids[i].attribute_key;
}
return "";
}

} // namespace trace
OPENTELEMETRY_END_NAMESPACE
8 changes: 4 additions & 4 deletions api/include/opentelemetry/trace/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ class Tracer
template <class Rep, class Period>
void ForceFlush(std::chrono::duration<Rep, Period> timeout) noexcept
{
this->ForceFlushWithMicroseconds(
static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::microseconds>(timeout)));
this->ForceFlushWithMicroseconds(static_cast<uint64_t>(
std::chrono::duration_cast<std::chrono::microseconds>(timeout).count()));
}

virtual void ForceFlushWithMicroseconds(uint64_t timeout) noexcept = 0;
Expand All @@ -183,8 +183,8 @@ class Tracer
template <class Rep, class Period>
void Close(std::chrono::duration<Rep, Period> timeout) noexcept
{
this->CloseWithMicroseconds(
static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::microseconds>(timeout)));
this->CloseWithMicroseconds(static_cast<uint64_t>(
std::chrono::duration_cast<std::chrono::microseconds>(timeout).count()));
}

virtual void CloseWithMicroseconds(uint64_t timeout) noexcept = 0;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "opentelemetry/detail/preprocessor.h"

#define OPENTELEMETRY_ABI_VERSION_NO 0
#define OPENTELEMETRY_VERSION "1.0.0-rc3"
#define OPENTELEMETRY_VERSION "1.0.0-rc4"
#define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO)

// clang-format off
Expand Down
16 changes: 16 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ elif [[ "$1" == "cmake.legacy.test" ]]; then
make
make test
exit 0
elif [[ "$1" == "cmake.legacy.exporter.otprotocol.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
export BUILD_ROOT="${BUILD_DIR}"
${SRC_DIR}/tools/build-gtest.sh
${SRC_DIR}/tools/build-benchmark.sh
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_STANDARD=11 \
-DWITH_OTLP=ON \
"${SRC_DIR}"
grpc_cpp_plugin=`which grpc_cpp_plugin`
proto_make_file="CMakeFiles/opentelemetry_proto.dir/build.make"
sed -i "s~gRPC_CPP_PLUGIN_EXECUTABLE-NOTFOUND~$grpc_cpp_plugin~" ${proto_make_file} #fixme
make -j $(nproc)
cd exporters/otlp && make test
exit 0
elif [[ "$1" == "cmake.exporter.otprotocol.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
Expand Down
Loading

0 comments on commit a43028d

Please sign in to comment.