Skip to content

Commit be71306

Browse files
committed
Update ci and fix bugs
1 parent 973c645 commit be71306

File tree

4 files changed

+85
-23
lines changed

4 files changed

+85
-23
lines changed

.github/workflows/statsd.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,31 @@ jobs:
1616
name: CMake on Linux
1717
runs-on: ubuntu-latest
1818
steps:
19-
- name: checkout otel contrib statsd
19+
- name: checkout opentelemetry-cpp-contrib
2020
uses: actions/checkout@v3
2121
with:
22-
path: "otel_cpp_contrib"
23-
- name: checkout otel cpp
22+
path: opentelemetry-cpp-contrib
23+
submodules: "recursive"
24+
- name: checkout opentelemetry-cpp
2425
uses: actions/checkout@v3
2526
with:
2627
repository: "open-telemetry/opentelemetry-cpp"
2728
ref: "v1.20.0"
28-
path: "otel_cpp"
29+
path: "opentelemetry-cpp"
2930
submodules: "recursive"
3031
- name: setup
3132
run: |
3233
sudo apt update -y
33-
sudo apt install -y --no-install-recommends --no-install-suggests build-essential\
34+
sudo apt install -y --no-install-recommends --no-install-suggest \
35+
build-essential \
36+
cmake \
37+
ninja-build \
3438
ca-certificates wget git valgrind lcov
3539
- name: run tests
3640
run: |
37-
sudo $GITHUB_WORKSPACE/otel_cpp/ci/setup_googletest.sh
38-
mkdir -p "$GITHUB_WORKSPACE/otel_cpp/build"
39-
cd "$GITHUB_WORKSPACE/otel_cpp/build"
40-
cmake .. -DOPENTELEMETRY_INSTALL=ON
41-
cmake --build . -j$(nproc)
42-
cmake --install . --prefix "$HOME/prebuilt-otel"
43-
mkdir -p "$GITHUB_WORKSPACE/otel_cpp_contrib/exporters/statsd/build"
44-
cd "$GITHUB_WORKSPACE/otel_cpp_contrib/exporters/statsd/build"
45-
cmake .. "-DCMAKE_PREFIX_PATH=$HOME/prebuilt-otel" \
46-
-DBUILD_TESTING=ON -DWITH_EXAMPLES=ON
41+
sudo $GITHUB_WORKSPACE/opentelemetry-cpp/ci/setup_googletest.sh
42+
mkdir -p "$GITHUB_WORKSPACE/opentelemetry-cpp/build"
43+
cd "$GITHUB_WORKSPACE/opentelemetry-cpp/build"
44+
cmake .. -G Ninja -DOPENTELEMETRY_EXTERNAL_COMPONENT_PATH=$GITHUB_WORKSPACE/opentelemetry-cpp-contrib/exporters/statsd
4745
cmake --build . -j$(nproc)
48-
ctest
46+
ctest -j1 --output-on-failure

exporters/statsd/include/opentelemetry/exporters/statsd/metrics/exporter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
#include "opentelemetry/common/spin_lock_mutex.h"
77
#include "opentelemetry/common/timestamp.h"
8-
#include "opentelemetry/exporters/geneva/metrics/connection_string_parser.h"
9-
#include "opentelemetry/exporters/geneva/metrics/data_transport.h"
10-
#include "opentelemetry/exporters/geneva/metrics/exporter_options.h"
8+
#include "opentelemetry/exporters/statsd/metrics/connection_string_parser.h"
9+
#include "opentelemetry/exporters/statsd/metrics/data_transport.h"
10+
#include "opentelemetry/exporters/statsd/metrics/exporter_options.h"
1111
#include "opentelemetry/sdk/metrics/push_metric_exporter.h"
1212
#include "opentelemetry/sdk/metrics/data/metric_data.h"
1313

1414

1515
OPENTELEMETRY_BEGIN_NAMESPACE
1616
namespace exporter {
17-
namespace geneva {
17+
namespace statsd {
1818
namespace metrics {
1919

2020
constexpr size_t kBufferSize = 65360; // the maximum ETW payload (inclusive)
@@ -121,7 +121,7 @@ static std::string AttributeValueToString(
121121
} else if (nostd::holds_alternative<std::string>(value)) {
122122
result = nostd::get<std::string>(value);
123123
} else {
124-
LOG_WARN("[Geneva Metrics Exporter] AttributeValueToString - "
124+
LOG_WARN("[Statsd Metrics Exporter] AttributeValueToString - "
125125
" Nested attributes not supported - ignored");
126126
}
127127
return result;
@@ -133,6 +133,6 @@ static uint64_t UnixTimeToWindowsTicks(uint64_t unix_epoch_secs) {
133133
}
134134

135135
} // namespace metrics
136-
} // namespace geneva
136+
} // namespace statsd
137137
} // namespace exporter
138138
OPENTELEMETRY_END_NAMESPACE
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2021, OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#pragma once
15+
16+
#include <mutex>
17+
18+
#ifndef TOKENPASTE
19+
#define TOKENPASTE(x, y) x##y
20+
#endif
21+
22+
#ifndef TOKENPASTE2
23+
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
24+
#endif
25+
26+
#ifndef LOCKGUARD
27+
#define LOCKGUARD(macro_mutex) \
28+
std::lock_guard<decltype(macro_mutex)> TOKENPASTE2(__guard_, \
29+
__LINE__)(macro_mutex)
30+
#endif
31+
32+
#if defined(HAVE_CONSOLE_LOG) && !defined(LOG_DEBUG)
33+
// Log to console if there's no standard log facility defined
34+
#include <cstdio>
35+
#ifndef LOG_DEBUG
36+
#define LOG_DEBUG(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__)
37+
#define LOG_TRACE(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__)
38+
#define LOG_INFO(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__)
39+
#define LOG_WARN(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__)
40+
#define LOG_ERROR(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__)
41+
#endif
42+
#endif
43+
44+
#ifndef LOG_DEBUG
45+
// Don't log anything if there's no standard log facility defined
46+
#define LOG_DEBUG(fmt_, ...)
47+
#define LOG_TRACE(fmt_, ...)
48+
#define LOG_INFO(fmt_, ...)
49+
#define LOG_WARN(fmt_, ...)
50+
#define LOG_ERROR(fmt_, ...)
51+
#endif
52+
53+
// Annex K macros
54+
#if !defined(_MSC_VER)
55+
#ifndef strncpy_s
56+
#define strncpy_s(dest, destsz, src, count) \
57+
strncpy(dest, src, (destsz <= count) ? destsz : count)
58+
#endif
59+
#endif
60+
61+
// SAL macro
62+
#ifndef _Out_cap_
63+
#define _Out_cap_(size)
64+
#endif

exporters/statsd/include/opentelemetry/exporters/statsd/metrics/socket_tools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ typedef u_short sa_family_t;
109109
#endif
110110
#endif
111111

112-
#include "opentelemetry/exporters/geneva/metrics/macros.h"
112+
#include "opentelemetry/exporters/statsd/metrics/macros.h"
113113

114114
namespace net {
115115

0 commit comments

Comments
 (0)