Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for include_meta_data to send the data only or send it with some meta data fields #125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bulk_streaming = True
compressed_streaming = True
stream_only_new_samples = True
enabled = False
include_meta_data = True

[logs-config]
logs_file_name = /log/tfs.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
},
"enabled": {
"type": "boolean"
},
"include_meta_data": {
"type": "boolean"
}
}
},
Expand Down
13 changes: 12 additions & 1 deletion plugins/fluentd_telemetry_plugin/src/streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class UFMTelemetryConstants:
},{
"name": '--enable_streaming',
"help": "If true, the streaming will be started once the required configurations have been set"
},{
"name": '--include_meta_data',
"help": "If true, the streaming message will include some meta data fields, "
"like the streaming timestamp and message type"
},{
"name": '--stream_only_new_samples',
"help": "If True, the data will be streamed only in case new samples were pulled from the telemetry"
Expand Down Expand Up @@ -105,6 +109,7 @@ class UFMTelemetryStreamingConfigParser(ConfigParser):
STREAMING_SECTION_BULK_STREAMING = "bulk_streaming"
STREAMING_SECTION_STREAM_ONLY_NEW_SAMPLES = "stream_only_new_samples"
STREAMING_SECTION_ENABLED = "enabled"
STREAMING_SECTION_INCLUDE_META_DATA = "include_meta_data"

META_FIELDS_SECTION = "meta-fields"

Expand Down Expand Up @@ -159,6 +164,12 @@ def get_enable_streaming_flag(self):
self.STREAMING_SECTION_ENABLED,
False)

def get_include_meta_data_flag(self):
return self.safe_get_bool(self.args.include_meta_data,
self.STREAMING_SECTION,
self.STREAMING_SECTION_INCLUDE_META_DATA,
True)

def get_fluentd_host(self):
return self.get_config_value(self.args.fluentd_host,
self.FLUENTD_ENDPOINT_SECTION,
Expand Down Expand Up @@ -430,7 +441,7 @@ def _stream_data_to_fluentd(self, data_to_stream, fluentd_msg_tag=''):
"timestamp": datetime.datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M:%S'),
"type": "full",
"values": data_to_stream
}
} if self.config_parser.get_include_meta_data_flag() else data_to_stream

if self.compressed_streaming_flag:
compressed = gzip.compress(json.dumps(fluentd_message).encode('utf-8'))
Expand Down