|
| 1 | +/* |
| 2 | + * Copyright The OpenTelemetry Authors |
| 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 | + |
| 17 | +#pragma once |
| 18 | + |
| 19 | +#include <memory> |
| 20 | +#include <vector> |
| 21 | +#include "opentelemetry/logs/log_record.h" |
| 22 | +#include "opentelemetry/nostd/span.h" |
| 23 | +#include "opentelemetry/sdk/logs/processor.h" |
| 24 | + |
| 25 | +OPENTELEMETRY_BEGIN_NAMESPACE |
| 26 | +namespace sdk |
| 27 | +{ |
| 28 | +namespace logs |
| 29 | +{ |
| 30 | +/** |
| 31 | + * ExportResult is returned as result of exporting a batch of Log Records. |
| 32 | + */ |
| 33 | +enum class ExportResult |
| 34 | +{ |
| 35 | + // The batch was exported successfully |
| 36 | + kSuccess = 0, |
| 37 | + // The batch was exported unsuccessfully and was dropped, but can not be retried |
| 38 | + kFailure |
| 39 | +}; |
| 40 | + |
| 41 | +/** |
| 42 | + * LogExporter defines the interface that log exporters must implement. |
| 43 | + */ |
| 44 | +class LogExporter |
| 45 | +{ |
| 46 | +public: |
| 47 | + virtual ~LogExporter() = default; |
| 48 | + |
| 49 | + /** |
| 50 | + * Exports the batch of log records to their export destination. |
| 51 | + * This method must not be called concurrently for the same exporter instance. |
| 52 | + * The exporter may attempt to retry sending the batch, but should drop |
| 53 | + * and return kFailure after a certain timeout. |
| 54 | + * @param records a span of unique pointers to log records |
| 55 | + * @returns an ExportResult code (whether export was success or failure) |
| 56 | + */ |
| 57 | + virtual ExportResult Export( |
| 58 | + const nostd::span<std::unique_ptr<opentelemetry::logs::LogRecord>> &records) noexcept = 0; |
| 59 | + |
| 60 | + /** |
| 61 | + * Marks the exporter as ShutDown and cleans up any resources as required. |
| 62 | + * Shutdown should be called only once for each Exporter instance. |
| 63 | + * @param timeout minimum amount of microseconds to wait for shutdown before giving up and |
| 64 | + * returning failure. |
| 65 | + * @return true if the exporter shutdown succeeded, false otherwise |
| 66 | + */ |
| 67 | + virtual bool Shutdown( |
| 68 | + std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept = 0; |
| 69 | +}; |
| 70 | +} // namespace logs |
| 71 | +} // namespace sdk |
| 72 | +OPENTELEMETRY_END_NAMESPACE |
0 commit comments