Skip to content

Commit

Permalink
Merge branch 'support/improve_docs' into 'main'
Browse files Browse the repository at this point in the history
Improve documentation

See merge request app-frameworks/esp-insights!110
  • Loading branch information
shahpiyushv committed Aug 14, 2023
2 parents 723f4b9 + b4052eb commit cfdd71e
Show file tree
Hide file tree
Showing 48 changed files with 1,029 additions and 355 deletions.
68 changes: 67 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ variables:
MAKEFLAGS: "-j8 --no-keep-going"
APP_BUILD: "all"
GIT_SUBMODULE_STRATEGY: recursive
ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.0:2-2"
ESP_DOCS_PATH: "$CI_PROJECT_DIR"

before_script:
# add gitlab ssh key
Expand Down Expand Up @@ -187,7 +189,71 @@ unit_tests:
paths:
- $CI_PROJECT_DIR/components/esp_diag_data_store/test/python_tests/*html

push_master_to_github:
build_docs:
stage: build
image: $ESP_DOCS_ENV_IMAGE
tags:
- build_docs
artifacts:
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
expire_in: 4 days
# No cleaning when the artifacts
after_script: []
script:
- cd docs
- pip install -r requirements.txt
- build-docs -l en -t esp32

.deploy_docs_template:
stage: deploy
image: $ESP_DOCS_ENV_IMAGE
tags:
- deploy_docs
needs:
- build_docs
only:
changes:
- "docs/**/*"
script:
- source ${CI_PROJECT_DIR}/docs/utils.sh
- add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
- export GIT_VER=$(git describe --always)
- pip install -r ${CI_PROJECT_DIR}/docs/requirements.txt
- deploy-docs

deploy_docs_preview:
extends:
- .deploy_docs_template
except:
refs:
- main
variables:
TYPE: "preview"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY"
DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_USER"
DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH"
DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE"

deploy_docs_production:
extends:
- .deploy_docs_template
only:
refs:
- main
variables:
TYPE: "production"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY"
DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_USER"
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE"

push_main_to_github:
stage: deploy
image: espressif/idf:release-v5.0
tags:
Expand Down
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Having remote diagnostics facility helps in identifying such issues faster. ESP

![Insights Overview](docs/_static/overview.png)

Currently, developers can monitor the following information from the web-based dashboard:
Developers can monitor the following information from the web-based dashboard:

- Error logs: Anything that is logged on console with calls with ESP_LOGE by any component in the firmware
- Warning logs: Anything that is logged on console with calls with ESP_LOGW by any component in the firmware
Expand All @@ -34,6 +34,12 @@ You can find more details on [Insights Features](FEATURES.md) page.
## Getting Started
Following code should get you started, and your application can start reporting ESP Insights data to the Insights cloud.

### Enabling ESP-Insights
By default, `ESP-Insights` is disabled. User need to enable it via menuconfig option.
`(Component config → ESP Insights)`

To select transport to be used, please follow next step.

### Enabling Insights with HTTPS
For Insights agent HTTPS is configure as the default transport.

Expand Down Expand Up @@ -62,7 +68,7 @@ Here is how you can obtain the ESP Insights Auth Key:

### Enabling Insights with MQTT
Configure the default insights transport to MQTT (Component config → ESP Insights → Insights default transport → MQTT).
Alternately you can add `CONFIG_ESP_INSIGHTS_TRANSPORT_MQTT=y` to `sdkconfig.defaults`.
Alternatively, you can add `CONFIG_ESP_INSIGHTS_TRANSPORT_MQTT=y` to `sdkconfig.defaults`.

```c
#include <esp_insights.h>
Expand All @@ -80,3 +86,32 @@ Alternately you can add `CONFIG_ESP_INSIGHTS_TRANSPORT_MQTT=y` to `sdkconfig.def
You will require the MQTT certs which you can obtain by performing [Claiming](examples/minimal_diagnostics#esp-insights-over-mqtt).

For more details please head over to [examples](examples).

## Behind the Scenes

- As described in the overview section, ESP-Insights collects data of your choice and stores it in storage, the storage currently used is RTC store.
- The data is split into two sections, and the size is configurable via menuconfig:
- Critical: Errors, Warnings and Events
- Non-Critical: Metrics and Variables
- This data is then periodically encoded in CBOR format and is sent over the transport.
- The data send algorithm is dynamic withing a range. It adapts to the need of the reporting.

### RTC data store
ESP-Insight currently uses RTC memory to store the messages until it is sent to the cloud. Unlike, normal RAM, RTC store makes data available across soft resets. Thus, it brodens the usefulness of the data across reboot.

Messages in Critical data take `121` bytes per message. Hence, one can calculate, say a `2048` bytes of critical section can hold `16` messages before it starts dropping new messages.
Likewise Non-critical messages take `49` bytes per message and hence a `1024` bytes storage can hold `21` messages.

The RTC memory is limited and flooding too many messages, makes RTC storage full. Once full, the framework has to drop the messages.
One solution is to increase the data reporting frequency to cloud, and thereby emptying the RTC store frequently.
> **_Note_**
This however comes with the network cost. It is advisable for a developer to keep Insights logging concise and not overdo it.

## Contributing

If you find an issue with ESP-Insights, or wish to submit an enhancement request, please use the Issues section on Github.
For ESP-IDF related issues please use [esp-idf](https://github.com/espressif/esp-idf) repo.

## License

ESP-Insights code is covered under Apache2 license. Submodules and other third party repos have their own license.
2 changes: 2 additions & 0 deletions components/esp_diag_data_store/include/esp_diag_data_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
extern "C" {
#endif

/** @cond **/
/**
* @brief Data store event base
*/
ESP_EVENT_DECLARE_BASE(ESP_DIAG_DATA_STORE_EVENT);
/** @endcond **/

/**
* @brief Data store events
Expand Down
18 changes: 5 additions & 13 deletions components/esp_diag_data_store/src/rtc_store/rtc_store.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdint.h>
#include <string.h>
Expand Down
19 changes: 6 additions & 13 deletions components/esp_diag_data_store/src/rtc_store/rtc_store.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include <esp_err.h>
#include <esp_event.h>

Expand Down
18 changes: 5 additions & 13 deletions components/esp_diag_data_store/test/test_data_store.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <string.h>
#include <esp_err.h>
Expand Down
18 changes: 5 additions & 13 deletions components/esp_diagnostics/include/esp_diagnostics.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

Expand Down
19 changes: 6 additions & 13 deletions components/esp_diagnostics/include/esp_diagnostics_metrics.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once
#include <stdbool.h>
#include <esp_err.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#ifdef __cplusplus
Expand Down
20 changes: 7 additions & 13 deletions components/esp_diagnostics/include/esp_diagnostics_variables.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include <stdbool.h>
#include <esp_err.h>
#include <esp_diagnostics.h>
Expand Down
18 changes: 5 additions & 13 deletions components/esp_diagnostics/src/esp_diagnostics_heap_metrics.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <string.h>
#include <esp_heap_caps.h>
Expand Down
19 changes: 6 additions & 13 deletions components/esp_diagnostics/src/esp_diagnostics_internal.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit cfdd71e

Please sign in to comment.