Skip to content

Commit

Permalink
open_telemetry plugin: Move prototypes to a header file.
Browse files Browse the repository at this point in the history
  • Loading branch information
octo committed Feb 20, 2024
1 parent c56c79c commit 3f17d33
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ endif
if BUILD_PLUGIN_OPEN_TELEMETRY
pkglib_LTLIBRARIES += open_telemetry.la
open_telemetry_la_SOURCES = \
src/open_telemetry.cc \
src/open_telemetry.cc src/open_telemetry.h \
src/open_telemetry_exporter.cc \
src/open_telemetry_receiver.cc \
opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
Expand Down
3 changes: 1 addition & 2 deletions src/open_telemetry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ extern "C" {
#include "daemon/plugin.h"
}

int exporter_config(oconfig_item_t *ci);
int receiver_config(oconfig_item_t *ci);
#include "open_telemetry.h"

static int ot_config(oconfig_item_t *ci) {
for (int i = 0; i < ci->children_num; i++) {
Expand Down
42 changes: 42 additions & 0 deletions src/open_telemetry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* collectd - src/open_telemetry.h
* Copyright (C) 2024 Florian octo Forster
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Florian octo Forster <octo at collectd.org>
**/

#ifndef OPEN_TELEMETRY_H
#define OPEN_TELEMETRY_H 1

extern "C" {
#include "daemon/collectd.h"
#include "daemon/configfile.h"
}

#include <grpc++/grpc++.h>

int exporter_config(oconfig_item_t *ci);
int receiver_config(oconfig_item_t *ci);

int config_get_file(oconfig_item_t const *ci, grpc::string *out);

#endif
3 changes: 2 additions & 1 deletion src/open_telemetry_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ extern "C" {
}

#include <fstream>

#include <grpc++/grpc++.h>

#include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h"
#include "utils/format_open_telemetry/format_open_telemetry.h"

#include "open_telemetry.h"

#ifndef OT_DEFAULT_PORT
#define OT_DEFAULT_PORT "4317"
#endif
Expand Down
5 changes: 2 additions & 3 deletions src/open_telemetry_receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ extern "C" {
#include "opentelemetry/proto/metrics/v1/metrics.pb.h"
#include "opentelemetry/proto/resource/v1/resource.pb.h"

#include "open_telemetry.h"

#ifndef OT_DEFAULT_PORT
#define OT_DEFAULT_PORT "4317"
#endif
Expand Down Expand Up @@ -427,9 +429,6 @@ static void receiver_install_callbacks(void) {
done = true;
}

// config_get_file is implemented in src/open_telemetry_exporter.cc
int config_get_file(oconfig_item_t const *ci, grpc::string *out);

/*
* collectd plugin interface
*/
Expand Down

0 comments on commit 3f17d33

Please sign in to comment.