Skip to content

Commit

Permalink
Automatically generate semantic conventions from the spec (open-telem…
Browse files Browse the repository at this point in the history
…etry#873)

Moved the windows work around to the template.
  • Loading branch information
marcalff committed Jul 21, 2022
1 parent 74b5670 commit 1d508ba
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 44 deletions.
12 changes: 12 additions & 0 deletions api/include/opentelemetry/trace/semantic_conventions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
#pragma once

#include "opentelemetry/version.h"
/*
* Special considerations for FaasDocumentOperationValues::DELETE.
*
* The winnt.h header file is known to define a DELETE symbol,
* which collides with FaasDocumentOperationValues::DELETE.
*/
#ifdef _WIN32
# ifdef DELETE
# pragma message(__FILE__ ": removing define on DELETE")
# undef DELETE
# endif
#endif

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
Expand Down
2 changes: 2 additions & 0 deletions buildscripts/semantic-convention/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ docker run --rm \
-f /source code \
--template /templates/SemanticAttributes.h.j2 \
--output /output/semantic_conventions.h \
-Dsemconv=trace \
-Dclass=SemanticConventions \
-DschemaUrl=$SCHEMA_URL \
-Dnamespace_open="namespace trace {" \
Expand All @@ -48,6 +49,7 @@ docker run --rm \
-f /source code \
--template /templates/SemanticAttributes.h.j2 \
--output /output/semantic_conventions.h \
-Dsemconv=resource \
-Dclass=SemanticConventions \
-DschemaUrl=$SCHEMA_URL \
-Dnamespace_open="namespace sdk { namespace resource {" \
Expand Down
15 changes: 15 additions & 0 deletions buildscripts/semantic-convention/templates/SemanticAttributes.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@

#include "opentelemetry/version.h"

{%- if semconv == "trace" %}
/*
* Special considerations for FaasDocumentOperationValues::DELETE.
*
* The winnt.h header file is known to define a DELETE symbol,
* which collides with FaasDocumentOperationValues::DELETE.
*/
#ifdef _WIN32
# ifdef DELETE
# pragma message(__FILE__ ": removing define on DELETE")
# undef DELETE
# endif
#endif
{% endif %}

OPENTELEMETRY_BEGIN_NAMESPACE
{{namespace_open}}

Expand Down
11 changes: 1 addition & 10 deletions examples/grpc/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,9 @@
#include <iostream>
#include <memory>
#include <string>
#include "tracer_common.h"

#ifdef _WIN32
# ifdef DELETE
// winnt.h defines DELETE
// Causes a build error with FaasDocumentOperationValues::DELETE
# pragma message(__FILE__ ": removing define on DELETE")
# undef DELETE
# endif
#endif

#include "opentelemetry/trace/semantic_conventions.h"
#include "tracer_common.h"

using grpc::Channel;
using grpc::ClientContext;
Expand Down
12 changes: 1 addition & 11 deletions examples/grpc/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#endif

#include "opentelemetry/trace/context.h"
#include "opentelemetry/trace/semantic_conventions.h"
#include "opentelemetry/trace/span_context_kv_iterable_view.h"
#include "tracer_common.h"

Expand All @@ -20,17 +21,6 @@
#include <string>
#include <thread>

#ifdef _WIN32
# ifdef DELETE
// winnt.h defines DELETE
// Causes a build error with FaasDocumentOperationValues::DELETE
# pragma message(__FILE__ ": removing define on DELETE")
# undef DELETE
# endif
#endif

#include "opentelemetry/trace/semantic_conventions.h"

using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
Expand Down
12 changes: 1 addition & 11 deletions examples/http/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@

#include "opentelemetry/ext/http/client/http_client_factory.h"
#include "opentelemetry/ext/http/common/url_parser.h"
#include "tracer_common.h"

#ifdef _WIN32
# ifdef DELETE
// winnt.h defines DELETE
// Causes a build error with FaasDocumentOperationValues::DELETE
# pragma message(__FILE__ ": removing define on DELETE")
# undef DELETE
# endif
#endif

#include "opentelemetry/trace/semantic_conventions.h"
#include "tracer_common.h"

namespace
{
Expand Down
13 changes: 1 addition & 12 deletions examples/http/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@

#include "server.h"
#include "opentelemetry/trace/context.h"

#include "opentelemetry/trace/semantic_conventions.h"
#include "tracer_common.h"

#include <iostream>
#include <thread>

#ifdef _WIN32
# ifdef DELETE
// winnt.h defines DELETE
// Causes a build error with FaasDocumentOperationValues::DELETE
# pragma message(__FILE__ ": removing define on DELETE")
# undef DELETE
# endif
#endif

#include "opentelemetry/trace/semantic_conventions.h"

namespace
{

Expand Down

0 comments on commit 1d508ba

Please sign in to comment.