Skip to content

Commit 7e4043c

Browse files
herin049lzchen
andauthored
feat: add file exporter implementation (open-telemetry#5207)
* commit * finish added file exporters * update license headers * add changelog fragment * add test tox environments * commit * simplify tests * test improvements * fix lint errors * apply suggstions from ocelotl * update dependencies * update package version * update exporter to write one line for each batch of telemetry * introduce generic FileExporter class to reduce code duplication * tweak generic FileExporter class * add 'force_flush' method to log exporter * move temporality and aggregation helper functions to json common package * update documentation for file exporter * fix docs build error --------- Co-authored-by: Leighton Chen <lechen@microsoft.com>
1 parent 5a7e121 commit 7e4043c

28 files changed

Lines changed: 1998 additions & 3 deletions

File tree

‎.changelog/5207.added‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`opentelemetry-exporter-otlp-json-file`: Add OTLP JSON File exporter implementation

‎.github/workflows/lint.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,25 @@ jobs:
290290
- name: Run tests
291291
run: tox -e lint-opentelemetry-exporter-otlp-combined
292292

293+
lint-opentelemetry-exporter-otlp-json-file:
294+
name: opentelemetry-exporter-otlp-json-file
295+
runs-on: ubuntu-latest
296+
timeout-minutes: 30
297+
steps:
298+
- name: Checkout repo @ SHA - ${{ github.sha }}
299+
uses: actions/checkout@v4
300+
301+
- name: Set up Python 3.14
302+
uses: actions/setup-python@v5
303+
with:
304+
python-version: "3.14"
305+
306+
- name: Install tox
307+
run: pip install tox-uv
308+
309+
- name: Run tests
310+
run: tox -e lint-opentelemetry-exporter-otlp-json-file
311+
293312
lint-opentelemetry-exporter-otlp-proto-grpc-latest:
294313
name: opentelemetry-exporter-otlp-proto-grpc-latest
295314
runs-on: ubuntu-latest

‎.github/workflows/test.yml‎

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,139 @@ jobs:
20982098
- name: Run tests
20992099
run: tox -e py314-test-opentelemetry-exporter-otlp-combined -- -ra
21002100

2101+
py310-test-opentelemetry-exporter-otlp-json-file_ubuntu-latest:
2102+
name: opentelemetry-exporter-otlp-json-file 3.10 Ubuntu
2103+
runs-on: ubuntu-latest
2104+
timeout-minutes: 30
2105+
steps:
2106+
- name: Checkout repo @ SHA - ${{ github.sha }}
2107+
uses: actions/checkout@v4
2108+
2109+
- name: Set up Python 3.10
2110+
uses: actions/setup-python@v5
2111+
with:
2112+
python-version: "3.10"
2113+
2114+
- name: Install tox
2115+
run: pip install tox-uv
2116+
2117+
- name: Run tests
2118+
run: tox -e py310-test-opentelemetry-exporter-otlp-json-file -- -ra
2119+
2120+
py311-test-opentelemetry-exporter-otlp-json-file_ubuntu-latest:
2121+
name: opentelemetry-exporter-otlp-json-file 3.11 Ubuntu
2122+
runs-on: ubuntu-latest
2123+
timeout-minutes: 30
2124+
steps:
2125+
- name: Checkout repo @ SHA - ${{ github.sha }}
2126+
uses: actions/checkout@v4
2127+
2128+
- name: Set up Python 3.11
2129+
uses: actions/setup-python@v5
2130+
with:
2131+
python-version: "3.11"
2132+
2133+
- name: Install tox
2134+
run: pip install tox-uv
2135+
2136+
- name: Run tests
2137+
run: tox -e py311-test-opentelemetry-exporter-otlp-json-file -- -ra
2138+
2139+
py312-test-opentelemetry-exporter-otlp-json-file_ubuntu-latest:
2140+
name: opentelemetry-exporter-otlp-json-file 3.12 Ubuntu
2141+
runs-on: ubuntu-latest
2142+
timeout-minutes: 30
2143+
steps:
2144+
- name: Checkout repo @ SHA - ${{ github.sha }}
2145+
uses: actions/checkout@v4
2146+
2147+
- name: Set up Python 3.12
2148+
uses: actions/setup-python@v5
2149+
with:
2150+
python-version: "3.12"
2151+
2152+
- name: Install tox
2153+
run: pip install tox-uv
2154+
2155+
- name: Run tests
2156+
run: tox -e py312-test-opentelemetry-exporter-otlp-json-file -- -ra
2157+
2158+
py313-test-opentelemetry-exporter-otlp-json-file_ubuntu-latest:
2159+
name: opentelemetry-exporter-otlp-json-file 3.13 Ubuntu
2160+
runs-on: ubuntu-latest
2161+
timeout-minutes: 30
2162+
steps:
2163+
- name: Checkout repo @ SHA - ${{ github.sha }}
2164+
uses: actions/checkout@v4
2165+
2166+
- name: Set up Python 3.13
2167+
uses: actions/setup-python@v5
2168+
with:
2169+
python-version: "3.13"
2170+
2171+
- name: Install tox
2172+
run: pip install tox-uv
2173+
2174+
- name: Run tests
2175+
run: tox -e py313-test-opentelemetry-exporter-otlp-json-file -- -ra
2176+
2177+
py314-test-opentelemetry-exporter-otlp-json-file_ubuntu-latest:
2178+
name: opentelemetry-exporter-otlp-json-file 3.14 Ubuntu
2179+
runs-on: ubuntu-latest
2180+
timeout-minutes: 30
2181+
steps:
2182+
- name: Checkout repo @ SHA - ${{ github.sha }}
2183+
uses: actions/checkout@v4
2184+
2185+
- name: Set up Python 3.14
2186+
uses: actions/setup-python@v5
2187+
with:
2188+
python-version: "3.14"
2189+
2190+
- name: Install tox
2191+
run: pip install tox-uv
2192+
2193+
- name: Run tests
2194+
run: tox -e py314-test-opentelemetry-exporter-otlp-json-file -- -ra
2195+
2196+
py314t-test-opentelemetry-exporter-otlp-json-file_ubuntu-latest:
2197+
name: opentelemetry-exporter-otlp-json-file 3.14t Ubuntu
2198+
runs-on: ubuntu-latest
2199+
timeout-minutes: 30
2200+
steps:
2201+
- name: Checkout repo @ SHA - ${{ github.sha }}
2202+
uses: actions/checkout@v4
2203+
2204+
- name: Set up Python 3.14t
2205+
uses: actions/setup-python@v5
2206+
with:
2207+
python-version: "3.14t"
2208+
2209+
- name: Install tox
2210+
run: pip install tox-uv
2211+
2212+
- name: Run tests
2213+
run: tox -e py314t-test-opentelemetry-exporter-otlp-json-file -- -ra
2214+
2215+
pypy3-test-opentelemetry-exporter-otlp-json-file_ubuntu-latest:
2216+
name: opentelemetry-exporter-otlp-json-file pypy-3.10 Ubuntu
2217+
runs-on: ubuntu-latest
2218+
timeout-minutes: 30
2219+
steps:
2220+
- name: Checkout repo @ SHA - ${{ github.sha }}
2221+
uses: actions/checkout@v4
2222+
2223+
- name: Set up Python pypy-3.10
2224+
uses: actions/setup-python@v5
2225+
with:
2226+
python-version: "pypy-3.10"
2227+
2228+
- name: Install tox
2229+
run: pip install tox-uv
2230+
2231+
- name: Run tests
2232+
run: tox -e pypy3-test-opentelemetry-exporter-otlp-json-file -- -ra
2233+
21012234
py310-test-opentelemetry-exporter-otlp-proto-grpc-oldest_ubuntu-latest:
21022235
name: opentelemetry-exporter-otlp-proto-grpc-oldest 3.10 Ubuntu
21032236
runs-on: ubuntu-latest
@@ -5651,6 +5784,153 @@ jobs:
56515784
- name: Run tests
56525785
run: tox -e py314-test-opentelemetry-exporter-otlp-combined -- -ra
56535786

5787+
py310-test-opentelemetry-exporter-otlp-json-file_windows-latest:
5788+
name: opentelemetry-exporter-otlp-json-file 3.10 Windows
5789+
runs-on: windows-latest
5790+
timeout-minutes: 30
5791+
steps:
5792+
- name: Configure git to support long filenames
5793+
run: git config --system core.longpaths true
5794+
- name: Checkout repo @ SHA - ${{ github.sha }}
5795+
uses: actions/checkout@v4
5796+
5797+
- name: Set up Python 3.10
5798+
uses: actions/setup-python@v5
5799+
with:
5800+
python-version: "3.10"
5801+
5802+
- name: Install tox
5803+
run: pip install tox-uv
5804+
5805+
- name: Run tests
5806+
run: tox -e py310-test-opentelemetry-exporter-otlp-json-file -- -ra
5807+
5808+
py311-test-opentelemetry-exporter-otlp-json-file_windows-latest:
5809+
name: opentelemetry-exporter-otlp-json-file 3.11 Windows
5810+
runs-on: windows-latest
5811+
timeout-minutes: 30
5812+
steps:
5813+
- name: Configure git to support long filenames
5814+
run: git config --system core.longpaths true
5815+
- name: Checkout repo @ SHA - ${{ github.sha }}
5816+
uses: actions/checkout@v4
5817+
5818+
- name: Set up Python 3.11
5819+
uses: actions/setup-python@v5
5820+
with:
5821+
python-version: "3.11"
5822+
5823+
- name: Install tox
5824+
run: pip install tox-uv
5825+
5826+
- name: Run tests
5827+
run: tox -e py311-test-opentelemetry-exporter-otlp-json-file -- -ra
5828+
5829+
py312-test-opentelemetry-exporter-otlp-json-file_windows-latest:
5830+
name: opentelemetry-exporter-otlp-json-file 3.12 Windows
5831+
runs-on: windows-latest
5832+
timeout-minutes: 30
5833+
steps:
5834+
- name: Configure git to support long filenames
5835+
run: git config --system core.longpaths true
5836+
- name: Checkout repo @ SHA - ${{ github.sha }}
5837+
uses: actions/checkout@v4
5838+
5839+
- name: Set up Python 3.12
5840+
uses: actions/setup-python@v5
5841+
with:
5842+
python-version: "3.12"
5843+
5844+
- name: Install tox
5845+
run: pip install tox-uv
5846+
5847+
- name: Run tests
5848+
run: tox -e py312-test-opentelemetry-exporter-otlp-json-file -- -ra
5849+
5850+
py313-test-opentelemetry-exporter-otlp-json-file_windows-latest:
5851+
name: opentelemetry-exporter-otlp-json-file 3.13 Windows
5852+
runs-on: windows-latest
5853+
timeout-minutes: 30
5854+
steps:
5855+
- name: Configure git to support long filenames
5856+
run: git config --system core.longpaths true
5857+
- name: Checkout repo @ SHA - ${{ github.sha }}
5858+
uses: actions/checkout@v4
5859+
5860+
- name: Set up Python 3.13
5861+
uses: actions/setup-python@v5
5862+
with:
5863+
python-version: "3.13"
5864+
5865+
- name: Install tox
5866+
run: pip install tox-uv
5867+
5868+
- name: Run tests
5869+
run: tox -e py313-test-opentelemetry-exporter-otlp-json-file -- -ra
5870+
5871+
py314-test-opentelemetry-exporter-otlp-json-file_windows-latest:
5872+
name: opentelemetry-exporter-otlp-json-file 3.14 Windows
5873+
runs-on: windows-latest
5874+
timeout-minutes: 30
5875+
steps:
5876+
- name: Configure git to support long filenames
5877+
run: git config --system core.longpaths true
5878+
- name: Checkout repo @ SHA - ${{ github.sha }}
5879+
uses: actions/checkout@v4
5880+
5881+
- name: Set up Python 3.14
5882+
uses: actions/setup-python@v5
5883+
with:
5884+
python-version: "3.14"
5885+
5886+
- name: Install tox
5887+
run: pip install tox-uv
5888+
5889+
- name: Run tests
5890+
run: tox -e py314-test-opentelemetry-exporter-otlp-json-file -- -ra
5891+
5892+
py314t-test-opentelemetry-exporter-otlp-json-file_windows-latest:
5893+
name: opentelemetry-exporter-otlp-json-file 3.14t Windows
5894+
runs-on: windows-latest
5895+
timeout-minutes: 30
5896+
steps:
5897+
- name: Configure git to support long filenames
5898+
run: git config --system core.longpaths true
5899+
- name: Checkout repo @ SHA - ${{ github.sha }}
5900+
uses: actions/checkout@v4
5901+
5902+
- name: Set up Python 3.14t
5903+
uses: actions/setup-python@v5
5904+
with:
5905+
python-version: "3.14t"
5906+
5907+
- name: Install tox
5908+
run: pip install tox-uv
5909+
5910+
- name: Run tests
5911+
run: tox -e py314t-test-opentelemetry-exporter-otlp-json-file -- -ra
5912+
5913+
pypy3-test-opentelemetry-exporter-otlp-json-file_windows-latest:
5914+
name: opentelemetry-exporter-otlp-json-file pypy-3.10 Windows
5915+
runs-on: windows-latest
5916+
timeout-minutes: 30
5917+
steps:
5918+
- name: Configure git to support long filenames
5919+
run: git config --system core.longpaths true
5920+
- name: Checkout repo @ SHA - ${{ github.sha }}
5921+
uses: actions/checkout@v4
5922+
5923+
- name: Set up Python pypy-3.10
5924+
uses: actions/setup-python@v5
5925+
with:
5926+
python-version: "pypy-3.10"
5927+
5928+
- name: Install tox
5929+
run: pip install tox-uv
5930+
5931+
- name: Run tests
5932+
run: tox -e pypy3-test-opentelemetry-exporter-otlp-json-file -- -ra
5933+
56545934
py310-test-opentelemetry-exporter-otlp-proto-grpc-oldest_windows-latest:
56555935
name: opentelemetry-exporter-otlp-proto-grpc-oldest 3.10 Windows
56565936
runs-on: windows-latest

‎docs-requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sphinx-jekyll-builder==0.3.0
1010
./opentelemetry-semantic-conventions
1111
./opentelemetry-sdk
1212
./opentelemetry-proto
13+
./opentelemetry-proto-json
1314
./shim/opentelemetry-opencensus-shim
1415
./shim/opentelemetry-opentracing-shim
1516
./exporter/opentelemetry-exporter-otlp-proto-common

‎docs/exporter/otlp/otlp.rst‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,25 @@ opentelemetry.exporter.otlp.proto.grpc
5050
:members:
5151
:undoc-members:
5252
:show-inheritance:
53+
54+
opentelemetry.exporter.otlp.json.file
55+
---------------------------------------
56+
57+
.. automodule:: opentelemetry.exporter.otlp.json.file
58+
:no-members:
59+
:no-undoc-members:
60+
61+
.. automodule:: opentelemetry.exporter.otlp.json.file.trace_exporter
62+
:members:
63+
:undoc-members:
64+
:show-inheritance:
65+
66+
.. automodule:: opentelemetry.exporter.otlp.json.file.metric_exporter
67+
:members:
68+
:undoc-members:
69+
:show-inheritance:
70+
71+
.. automodule:: opentelemetry.exporter.otlp.json.file._log_exporter
72+
:members:
73+
:undoc-members:
74+
:show-inheritance:

‎eachdist.ini‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ packages=
3636
opentelemetry-exporter-opencensus
3737
opentelemetry-exporter-prometheus
3838
opentelemetry-exporter-otlp-json-common
39+
opentelemetry-exporter-otlp-json-file
3940
opentelemetry-distro
4041
opentelemetry-proto-json
4142
opentelemetry-semantic-conventions

‎exporter/opentelemetry-exporter-otlp-json-common/README.rst‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ OpenTelemetry JSON Encoding
66
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-otlp-json-common.svg
77
:target: https://pypi.org/project/opentelemetry-exporter-otlp-json-common/
88

9-
This library is provided as a convenience to encode to OTLP JSON. Currently used by:
10-
11-
-
9+
This library is provided as a convenience to encode to OTLP JSON.
1210

1311
Installation
1412
------------

0 commit comments

Comments
 (0)