Skip to content

Commit

Permalink
Merge branch 'main' into wip-thrift
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan authored Oct 19, 2021
2 parents 5e363fb + bfab71a commit ad67630
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 102 deletions.
53 changes: 19 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ git commit
git push fork feature
```

If you made changes to the Markdown documents (`*.md` files), install the latest
[`markdownlint-cli`](https:/igorshubovych/markdownlint-cli) and run:

```sh
markdownlint .
```

Open a pull request against the main `opentelemetry-cpp` repo.

To run tests locally, please read the [CI instructions](ci/README.md).
Expand Down Expand Up @@ -144,6 +151,14 @@ If none of the above worked and the PR has been stuck for more than 2 weeks, the
owner should bring it to the OpenTelemetry C++ SIG meeting. See
[README.md](README.md#contributing) for the meeting link.

## Design Choices

As with other OpenTelemetry clients, opentelemetry-cpp follows the
[opentelemetry-specification](https:/open-telemetry/opentelemetry-specification).

It's especially valuable to read through the [library
guidelines](https:/open-telemetry/opentelemetry-specification/blob/main/specification/library-guidelines.md).

## Useful Resources

Hi! If you’re looking at this document, these resources will provide you the
Expand All @@ -168,43 +183,13 @@ the C++ repository.
* The OpenTelemetry Specification describes the requirements and expectations
of for all OpenTelemetry implementations.

* Read through the [OpenTelemetry
Collector](https:/open-telemetry/opentelemetry-collector) GitHub
repository.
* This repository has a lot of good information surrounding the OpenTelemetry
ecosystem. At the top of the
**[readme](https:/open-telemetry/opentelemetry-collector/blob/main/README.md)**,
there are multiple links that give newcomers a good idea of what the project
is about and how to get involved in it.
* Read through the OpenTelemetry Python documentation
* Read through the OpenTelemetry C++ documentation
* The
[API](https://opentelemetry-python.readthedocs.io/en/stable/api/api.html)
[API](https://opentelemetry-cpp.readthedocs.io/en/latest/api/api.html)
and
[SDK](https://opentelemetry-python.readthedocs.io/en/stable/sdk/sdk.html)
[SDK](https://opentelemetry-cpp.readthedocs.io/en/latest/sdk/sdk.html)
documentation provides a lot of information on what the classes and their
functions are used for. Since there is currently minimal documentation for
C++, use the Python repository’s extensive documentation to learn more about
how the API and SDK work.

### Code Examples

* Follow the [simple trace
example](https:/open-telemetry/opentelemetry-cpp/pull/92) for an
introduction to basic OpenTelemetry functionality in C++. Currently the
example can be found in [PR
#94](https:/open-telemetry/opentelemetry-cpp/pull/94).

* Read through the [Java Quick-Start
Guide](https:/open-telemetry/opentelemetry-java/blob/main/QUICKSTART.md).
This shows you how the classes and functions will interact in simple and easy
to digest examples.
* Take a look at this [Java SDK
example](https:/open-telemetry/opentelemetry-java/tree/main/examples/sdk-usage).
This shows a good use case of the SDK using stdout exporter.
* Take a look at the [Java Jaeger
example](https:/open-telemetry/opentelemetry-java/tree/main/examples/jaeger).
This provides a brief introduction to the Jaeger exporter, its interface, and
how to interact with the service.
functions are used for.

Please contribute! You’re welcome to add more information if you come across any
helpful resources.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ of the current project.

| Platform | Build type |
|---------------------------------------------------------------------|---------------|
| ubuntu-18.04 (Default GCC Compiler - 7.5.0) | CMake, Bazel |
| ubuntu-20.04 (Default GCC Compiler - 9.3.0) | CMake, Bazel |
| ubuntu-18.04 (GCC 4.8 with -std=c++11 flag) | CMake [1] |
| ubuntu-20.04 (Default GCC Compiler - 9.3.0 with -std=c++20 flags) | CMake, Bazel |
| macOS 10.15 (Xcode 12.2) | Bazel |
Expand Down
2 changes: 1 addition & 1 deletion docs/public/sdk/GettingStarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ OpenTelemetry offers six tracing exporters out of the box:
// otlp http exporter
opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts;
opts.url = "http://localhost:4317/v1/traces";
opts.url = "http://localhost:4318/v1/traces";
auto otlp_http_exporter =
std::unique_ptr<sdktrace::SpanExporter>(new opentelemetry::exporter::otlp::OtlpHttpExporter(opts));
Expand Down
9 changes: 4 additions & 5 deletions examples/otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@ OpenTelemetry Collector with an OTLP receiver by running:
- On Unix based systems use:

```console
docker run --rm -it -p 4317:4317 -p 55681:55681 -v $(pwd)/examples/otlp:/cfg otel/opentelemetry-collector:0.19.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml
docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd)/examples/otlp:/cfg otel/opentelemetry-collector:0.19.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml
```

- On Windows use:

```console
docker run --rm -it -p 4317:4317 -p 55681:55681 -v "%cd%/examples/otlp":/cfg otel/opentelemetry-collector:0.19.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml
docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%/examples/otlp":/cfg otel/opentelemetry-collector:0.19.0 --config=/cfg/opentelemetry-collector-config/config.dev.yaml
```

Note that the OTLP exporter connects to the Collector at `localhost:4317` by
default. This can be changed with first argument from command-line, for example:
Note that the OTLP gRPC and HTTP exporters connects to the Collector at `localhost:4317` and `localhost:4318:/v1/traces` respectively. This can be changed with first argument from command-line, for example:
`./example_otlp_grpc gateway.docker.internal:4317` and
`./example_otlp_http gateway.docker.internal:55681/v1/traces`.
`./example_otlp_http gateway.docker.internal:4318/v1/traces`.

Once you have the Collector running, see
[CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ receivers:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: "0.0.0.0:55681"
endpoint: "0.0.0.0:4318"
cors_allowed_origins:
- '*'
service:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Logger : public logs::Logger
{
static ETWProvider instance; // C++11 magic static
return instance;
};
}

/**
* @brief Init a reference to etw::ProviderHandle
Expand Down
47 changes: 25 additions & 22 deletions exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PropertyValue : public PropertyVariant
static std::vector<T> to_vector(const nostd::span<const T, nostd::dynamic_extent> &source)
{
return std::vector<T>(source.begin(), source.end());
};
}

/**
* @brief Convert span<string_view> to vector<string>
Expand All @@ -98,7 +98,7 @@ class PropertyValue : public PropertyVariant
result.push_back(std::string(item.data()));
}
return result;
};
}

/**
* @brief Convert vector<INTEGRAL> to span<INTEGRAL>.
Expand All @@ -111,7 +111,7 @@ class PropertyValue : public PropertyVariant
{
nostd::span<const T> result(vec.data(), vec.size());
return result;
};
}

/**
* @brief Convert vector<FLOAT> to span<const FLOAT>.
Expand All @@ -124,69 +124,72 @@ class PropertyValue : public PropertyVariant
{
nostd::span<const T> result(vec.data(), vec.size());
return result;
};
}

public:
/**
* @brief PropertyValue from bool
* @param v
* @return
*/
PropertyValue(bool value) : PropertyVariant(value){};
PropertyValue(bool value) : PropertyVariant(value) {}

/**
* @brief PropertyValue from integral.
* @param v
* @return
*/
template <typename TInteger, std::enable_if_t<std::is_integral<TInteger>::value, bool> = true>
PropertyValue(TInteger number) : PropertyVariant(number){};
PropertyValue(TInteger number) : PropertyVariant(number)
{}

/**
* @brief PropertyValue from floating point.
* @param v
* @return
*/
template <typename TFloat, std::enable_if_t<std::is_floating_point<TFloat>::value, bool> = true>
PropertyValue(TFloat number) : PropertyVariant(double(number)){};
PropertyValue(TFloat number) : PropertyVariant(double(number))
{}

/**
* @brief Default PropertyValue (int32_t=0)
* @param v
* @return
*/
PropertyValue() : PropertyVariant(int32_t(0)){};
PropertyValue() : PropertyVariant(int32_t(0)) {}

/**
* @brief PropertyValue from array of characters as string.
*
* @param v
* @return
*/
PropertyValue(char value[]) : PropertyVariant(std::string(value)){};
PropertyValue(char value[]) : PropertyVariant(std::string(value)) {}

/**
* @brief PropertyValue from array of characters as string.
*
* @param v
* @return
*/
PropertyValue(const char *value) : PropertyVariant(std::string(value)){};
PropertyValue(const char *value) : PropertyVariant(std::string(value)) {}

/**
* @brief PropertyValue from string.
*
* @param v
* @return
*/
PropertyValue(const std::string &value) : PropertyVariant(value){};
PropertyValue(const std::string &value) : PropertyVariant(value) {}

/**
* @brief PropertyValue from vector as array.
* @return
*/
template <typename T>
PropertyValue(std::vector<T> value) : PropertyVariant(value){};
PropertyValue(std::vector<T> value) : PropertyVariant(value)
{}

/**
* @brief Convert owning PropertyValue to non-owning common::AttributeValue
Expand Down Expand Up @@ -217,11 +220,11 @@ class PropertyValue : public PropertyVariant
case common::AttributeType::kTypeCString: {
PropertyVariant::operator=(nostd::get<const char *>(v));
break;
};
}
case common::AttributeType::kTypeString: {
PropertyVariant::operator=(nostd::string_view(nostd::get<nostd::string_view>(v)).data());
break;
};
}

case common::AttributeType::kTypeSpanByte:
PropertyVariant::operator=(to_vector(nostd::get<nostd::span<const uint8_t>>(v)));
Expand Down Expand Up @@ -361,15 +364,15 @@ class Properties : public common::KeyValueIterable, public PropertyValueMap
/**
* @brief PropertyValueMap constructor.
*/
Properties() : PropertyValueMap(){};
Properties() : PropertyValueMap() {}

/**
* @brief PropertyValueMap constructor from initializer list.
*/
Properties(const std::initializer_list<PropertyValueType> properties) : PropertyValueMap()
{
(*this) = (properties);
};
}

/**
* @brief PropertyValueMap assignment operator from initializer list.
Expand All @@ -378,12 +381,12 @@ class Properties : public common::KeyValueIterable, public PropertyValueMap
{
PropertyValueMap::operator=(properties);
return (*this);
};
}

/**
* @brief PropertyValueMap constructor from map.
*/
Properties(const PropertyValueMap &properties) : PropertyValueMap() { (*this) = properties; };
Properties(const PropertyValueMap &properties) : PropertyValueMap() { (*this) = properties; }

/**
* @brief PropertyValueMap assignment operator from map.
Expand All @@ -392,7 +395,7 @@ class Properties : public common::KeyValueIterable, public PropertyValueMap
{
PropertyValueMap::operator=(properties);
return (*this);
};
}

/**
* @brief PropertyValueMap constructor from KeyValueIterable
Expand All @@ -414,7 +417,7 @@ class Properties : public common::KeyValueIterable, public PropertyValueMap
return true;
});
return (*this);
};
}

/**
* @brief PropertyValueMap property accessor.
Expand All @@ -439,12 +442,12 @@ class Properties : public common::KeyValueIterable, public PropertyValueMap
}
}
return true;
};
}

/**
* @return the number of key-value pairs
*/
size_t size() const noexcept override { return PropertyValueMap::size(); };
size_t size() const noexcept override { return PropertyValueMap::size(); }
};

} // namespace etw
Expand Down
Loading

0 comments on commit ad67630

Please sign in to comment.